mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 18:27:10 +01:00
Patch for bug #53 on version 0.5.0
This is a patch that we have utilized at IDEXX Labs for the the bug described above. We have tested and verified this on x86 32 and 64 bit linux and 32 bit arm.
This commit is contained in:
parent
1ac2295c21
commit
bc5dbc6d41
@ -13,6 +13,7 @@
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
|
||||
// Disable warning about strdup being deprecated.
|
||||
@ -79,7 +80,29 @@ std::string valueToString(double value) {
|
||||
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||
#endif
|
||||
#else
|
||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
if ( isfinite( value ))
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// IEEE standard states that NaN values will not compare to themselves
|
||||
if ( value != value)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "null");
|
||||
}
|
||||
else if ( value < 0)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "-1e+9999");
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "1e+9999");
|
||||
}
|
||||
// nothing more to do, return.
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif
|
||||
fixNumericLocale(buffer, buffer + strlen(buffer));
|
||||
return buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user