extract variable

This commit is contained in:
cmlchen 2019-06-25 11:26:29 +08:00 committed by Jordan Bayles
parent 7c7ccbf934
commit c51d718ead

View File

@ -852,9 +852,11 @@ bool Value::asBool() const {
return value_.int_ ? true : false;
case uintValue:
return value_.uint_ ? true : false;
case realValue:
// According to JavaScript language zero or NaN is regarded as false
return std::fpclassify(value_.real_) != FP_ZERO && std::fpclassify(value_.real_) != FP_NAN;
case realValue: {
// According to JavaScript language zero or NaN is regarded as false
const auto value_classification = std::fpclassify(value_.real_);
return value_classification != FP_ZERO && value_classification != FP_NAN;
}
default:
break;
}