fixes to nuon for inf, -inf, and NaN (#5818)

This commit is contained in:
pwygab
2022-06-18 02:01:37 +08:00
committed by GitHub
parent a17d46f200
commit 28c21121cf
2 changed files with 41 additions and 1 deletions

View File

@ -87,7 +87,11 @@ fn value_to_string(v: &Value, span: Span) -> Result<String, ShellError> {
)),
Value::Filesize { val, .. } => Ok(format!("{}b", *val)),
Value::Float { val, .. } => {
if &val.round() == val {
if &val.round() == val
&& val != &f64::NAN
&& val != &f64::INFINITY
&& val != &f64::NEG_INFINITY
{
Ok(format!("{}.0", *val))
} else {
Ok(format!("{}", *val))