MCPcopy Create free account
hub / github.com/Wassimulator/CactusViewer / cJSON_CreateNumber

Function cJSON_CreateNumber

src/cJSON.c:2429–2453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2427}
2428
2429CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2430{
2431 cJSON *item = cJSON_New_Item(&global_hooks);
2432 if(item)
2433 {
2434 item->type = cJSON_Number;
2435 item->valuedouble = num;
2436
2437 /* use saturation in case of overflow */
2438 if (num >= INT_MAX)
2439 {
2440 item->valueint = INT_MAX;
2441 }
2442 else if (num <= (double)INT_MIN)
2443 {
2444 item->valueint = INT_MIN;
2445 }
2446 else
2447 {
2448 item->valueint = (int)num;
2449 }
2450 }
2451
2452 return item;
2453}
2454
2455CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2456{

Callers 5

save_settingsFunction · 0.85
cJSON_AddNumberToObjectFunction · 0.85
cJSON_CreateIntArrayFunction · 0.85
cJSON_CreateFloatArrayFunction · 0.85
cJSON_CreateDoubleArrayFunction · 0.85

Calls 1

cJSON_New_ItemFunction · 0.85

Tested by

no test coverage detected