We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5510f14 commit b7feb2dCopy full SHA for b7feb2d
src/lib_json/json_value.cpp
@@ -853,8 +853,8 @@ bool Value::asBool() const {
853
case uintValue:
854
return value_.uint_ ? true : false;
855
case realValue:
856
- // This is kind of strange. Not recommended.
857
- 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
858
default:
859
break;
860
}
0 commit comments