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

Function cJSON_CreateNumber

contrib/cJSON/cJSON.cpp:2306–2330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2304}
2305
2306CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2307{
2308 cJSON *item = cJSON_New_Item(&global_hooks);
2309 if(item)
2310 {
2311 item->type = cJSON_Number;
2312 item->valuedouble = num;
2313
2314 /* use saturation in case of overflow */
2315 if (num >= INT_MAX)
2316 {
2317 item->valueint = INT_MAX;
2318 }
2319 else if (num <= INT_MIN)
2320 {
2321 item->valueint = INT_MIN;
2322 }
2323 else
2324 {
2325 item->valueint = (int)num;
2326 }
2327 }
2328
2329 return item;
2330}
2331
2332CJSON_PUBLIC(cJSON *) cJSON_CreateInt64(long long num)
2333{

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