diff --git a/CHANGELOG.md b/CHANGELOG.md index f7de172a..ad096ea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ Rhai Release Notes ================== +Version 1.1.2 +============= + +Bug fixes +--------- + +* `0.0` now prints correctly (used to print `0e0`). + + Version 1.1.1 ============= diff --git a/src/ast.rs b/src/ast.rs index 34d492a5..a344607b 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1825,7 +1825,9 @@ impl fmt::Debug for FloatWrapper { impl> fmt::Display for FloatWrapper { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let abs = self.0.abs(); - if abs > Self::MAX_NATURAL_FLOAT_FOR_DISPLAY.into() + if abs.fract().is_zero() { + f.write_str("0.0") + } else if abs > Self::MAX_NATURAL_FLOAT_FOR_DISPLAY.into() || abs < Self::MIN_NATURAL_FLOAT_FOR_DISPLAY.into() { write!(f, "{:e}", self.0)