mirror of
https://github.com/DaveGamble/cJSON.git
synced 2026-10-31 13:00:51 +00:00
improve compare_double function
This commit is contained in:
1 parent
1f970e7db3
commit
c06d8264d0
2 files changed
+3
-3
No files matched your search
@@ -483,7 +483,7 @@ static void update_offset(printbuffer * const buffer)
|
|||||||
/* securely comparison of floating-point variables */
|
/* securely comparison of floating-point variables */
|
||||||
static cJSON_bool compare_double(double a, double b)
|
static cJSON_bool compare_double(double a, double b)
|
||||||
{
|
{
|
||||||
return (fabs(a - b) <= a * CJSON_DOUBLE_PRECIION);
|
return (fabs(a - b) <= CJSON_DOUBLE_PRECISION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Render the number nicely from the given item into a string. */
|
/* Render the number nicely from the given item into a string. */
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ typedef int cJSON_bool;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Precision of double variables comparison */
|
/* Precision of double variables comparison */
|
||||||
#ifndef CJSON_DOUBLE_PRECIION
|
#ifndef CJSON_DOUBLE_PRECISION
|
||||||
#define CJSON_DOUBLE_PRECIION .00001
|
#define CJSON_DOUBLE_PRECISION .0000000000000001
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* returns the version of cJSON as a string */
|
/* returns the version of cJSON as a string */
|
||||||
|
|||||||
Reference in new issue
Block a user