mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
is_nan and is_infinity macros
This commit is contained in:
6
cJSON.c
6
cJSON.c
@@ -471,6 +471,9 @@ static void update_offset(printbuffer * const buffer)
|
||||
buffer->offset += strlen((const char*)buffer_pointer);
|
||||
}
|
||||
|
||||
#define is_nan(number) (number != number)
|
||||
#define is_infinity(number) (!is_nan(number) && (number * 0) != 0)
|
||||
|
||||
/* Render the number nicely from the given item into a string. */
|
||||
static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer)
|
||||
{
|
||||
@@ -487,8 +490,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This checks for NaN and Infinity */
|
||||
if ((d * 0) != 0)
|
||||
if (is_nan(d) || is_infinity(d))
|
||||
{
|
||||
length = sprintf((char*)number_buffer, "null");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user