MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / cJSON_CreateNumber

Function cJSON_CreateNumber

TheForceEngine/TFE_System/cJSON.c:2439–2463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2437}
2438
2439CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2440{
2441 cJSON *item = cJSON_New_Item(&global_hooks);
2442 if(item)
2443 {
2444 item->type = cJSON_Number;
2445 item->valuedouble = num;
2446
2447 /* use saturation in case of overflow */
2448 if (num >= INT_MAX)
2449 {
2450 item->valueint = INT_MAX;
2451 }
2452 else if (num <= (double)INT_MIN)
2453 {
2454 item->valueint = INT_MIN;
2455 }
2456 else
2457 {
2458 item->valueint = (int)num;
2459 }
2460 }
2461
2462 return item;
2463}
2464
2465CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2466{

Callers 4

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