mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-19 23:50:38 +02:00
valueToString: simplify lookup of special float name
This commit is contained in:
parent
a888632781
commit
b4e88e35be
@ -67,11 +67,11 @@ String valueToString(double value, bool useSpecialFloats,
|
|||||||
// that always has a decimal point because JSON doesn't distinguish the
|
// that always has a decimal point because JSON doesn't distinguish the
|
||||||
// concepts of reals and integers.
|
// concepts of reals and integers.
|
||||||
if (!std::isfinite(value)) {
|
if (!std::isfinite(value)) {
|
||||||
static const char* const reps[2][3] = {{"NaN", "-Infinity", "Infinity"},
|
if (std::isnan(value))
|
||||||
{"null", "-1e+9999", "1e+9999"}};
|
return useSpecialFloats ? "NaN" : "null";
|
||||||
return reps[useSpecialFloats ? 0 : 1][std::isnan(value) ? 0
|
if (value < 0)
|
||||||
: (value < 0) ? 1
|
return useSpecialFloats ? "-Infinity" : "-1e+9999";
|
||||||
: 2];
|
return useSpecialFloats ? "Infinity" : "1e+9999";
|
||||||
}
|
}
|
||||||
|
|
||||||
String buffer(size_t(36), '\0');
|
String buffer(size_t(36), '\0');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user