We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5b91551 commit 7e68fcdCopy full SHA for 7e68fcd
1 file changed
src/lib_json/json_value.cpp
@@ -848,8 +848,8 @@ bool Value::asBool() const {
848
case uintValue:
849
return value_.uint_ ? true : false;
850
case realValue:
851
- // This is kind of strange. Not recommended.
852
- 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
853
default:
854
break;
855
}
0 commit comments