diff --git a/CHANGELOG.md b/CHANGELOG.md index 31a8d41a..6d52f811 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ Rhai Release Notes ================== +Version 1.1.0 +============= + +Enhancements +------------ + +* `parse_float()`, `PI()` and `E()` now defer to `Decimal` under `no_float` if `decimal` is turned on. + + Version 1.0.2 ============= @@ -105,7 +114,7 @@ New features * Each `Dynamic` value can now contain arbitrary data (type `i32`) in the form of a _tag_. This is to use up otherwise wasted space in the `Dynamic` type. * A new internal feature `no_smartstring` to turn off `SmartString` for those rare cases that it is needed. * `DynamicReadLock` and `DynamicWriteLoc` are exposed under `internals`. -* `From>>` is added for `Dynamic` mapping directly to a shared value, together with support for `Dynamic::from`. +* `From< Shared< Locked > >` is added for `Dynamic` mapping directly to a shared value, together with support for `Dynamic::from`. * An indexer with string index acts as a _fallback_ to a property getter/setter. Enhancements diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index 2b07a5bc..53c0431b 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -309,6 +309,22 @@ mod decimal_functions { Decimal, MathematicalOps, }; + #[cfg(feature = "no_float")] + pub mod float_polyfills { + #[rhai_fn(name = "PI")] + pub fn pi() -> Decimal { + Decimal::PI + } + #[rhai_fn(name = "E")] + pub fn e() -> Decimal { + Decimal::E + } + #[rhai_fn(return_raw)] + pub fn parse_float(s: &str) -> Result> { + super::parse_decimal(s) + } + } + #[rhai_fn(return_raw)] pub fn sqrt(x: Decimal) -> Result> { x.sqrt()