MCPcopy Index your code
hub / github.com/antirez/botlib / cJSON_CreateNumber

Function cJSON_CreateNumber

cJSON.c:2420–2444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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