You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int64_t value = value_js->valueint;
int64_t value = value_js->valuedouble;
So, how to get "value" ?
The number is bigger than INT_MAX, "uint64_t value = value_js->valueint" will be wrong.
Use "uint64_t value = value_js->valuedouble" will have a type conversion. Is there any possiblity that type conversion will have some problem ?
So what is the right way to get int64_t value ? Thanks !
The text was updated successfully, but these errors were encountered:
There is no support for int64_t in C89, so cJSON doesn't support it. See #151 and #14.
You can use valuedouble to store up to 53 bit integers without loss of precision if you are using a system that uses IEEE 754 Double Precision Floating Point Numbers (which is almost every system out there).
valueint is only there for legacy purposes, if you use cJSON_SetNumberValue, valuedouble will be set to whatever you pass to it and valueint will be either the result of casting the double to int or INT_MAX, INT_MIN if the double is outside of the range of an int.
Same goes for cJSON_AddNumberToObject, but be careful because 1326545647980439 is an integer literal and will be truncated by the compiler, so you need to use 1326545647980439.0 (and since this number takes 51 bits, it will fit in IEEE754 doubles.
So, how to get "value" ?
The number is bigger than INT_MAX, "uint64_t value = value_js->valueint" will be wrong.
Use "uint64_t value = value_js->valuedouble" will have a type conversion. Is there any possiblity that type conversion will have some problem ?
So what is the right way to get int64_t value ? Thanks !
The text was updated successfully, but these errors were encountered: