MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / cJSON_CreateNumber

Function cJSON_CreateNumber

libapp2sys/src/main/cpp/cjson/cJSON.c:2298–2322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2296}
2297
2298CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2299{
2300 cJSON *item = cJSON_New_Item(&global_hooks);
2301 if(item)
2302 {
2303 item->type = cJSON_Number;
2304 item->valuedouble = num;
2305
2306 /* use saturation in case of overflow */
2307 if (num >= INT_MAX)
2308 {
2309 item->valueint = INT_MAX;
2310 }
2311 else if (num <= (double)INT_MIN)
2312 {
2313 item->valueint = INT_MIN;
2314 }
2315 else
2316 {
2317 item->valueint = (int)num;
2318 }
2319 }
2320
2321 return item;
2322}
2323
2324CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2325{

Callers 8

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