| 2304 | } |
| 2305 | |
| 2306 | CJSON_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 | |
| 2332 | CJSON_PUBLIC(cJSON *) cJSON_CreateInt64(long long num) |
| 2333 | { |
no test coverage detected