MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / cJSON_CreateNumber

Function cJSON_CreateNumber

external/cJSON/cJSON.c:2505–2529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2503}
2504
2505CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2506{
2507 cJSON *item = cJSON_New_Item(&global_hooks);
2508 if(item)
2509 {
2510 item->type = cJSON_Number;
2511 item->valuedouble = num;
2512
2513 /* use saturation in case of overflow */
2514 if (num >= INT_MAX)
2515 {
2516 item->valueint = INT_MAX;
2517 }
2518 else if (num <= (double)INT_MIN)
2519 {
2520 item->valueint = INT_MIN;
2521 }
2522 else
2523 {
2524 item->valueint = (int)num;
2525 }
2526 }
2527
2528 return item;
2529}
2530
2531CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2532{

Callers 5

make_cjsonFunction · 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