MCPcopy Create free account
hub / github.com/OpenIPC/firmware / cJSON_CreateNumber

Function cJSON_CreateNumber

general/package/xmdp/src/cjson/cJSON.c:2427–2451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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