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