mirror of
https://github.com/DaveGamble/cJSON.git
synced 2026-10-14 10:20:05 +00:00
is_nan and is_infinity macros
This commit is contained in:
1 parent
3e2c29528a
commit
5ed383a0d1
2 files changed
+24
-2
No files matched your search
@@ -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