mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-14 09:57:56 +08:00
use fpclassify to test a float number is zero or nan
This commit is contained in:
parent
5510f14a71
commit
b7feb2d493
@ -853,8 +853,8 @@ bool Value::asBool() const {
|
|||||||
case uintValue:
|
case uintValue:
|
||||||
return value_.uint_ ? true : false;
|
return value_.uint_ ? true : false;
|
||||||
case realValue:
|
case realValue:
|
||||||
// This is kind of strange. Not recommended.
|
// According to JavaScript language zero or NaN is regarded as false
|
||||||
return (value_.real_ != 0.0) ? true : false;
|
return std::fpclassify(value_.real_) != FP_ZERO && std::fpclassify(value_.real_) != FP_NAN
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user