diff --git a/Cargo.toml b/Cargo.toml index 4c9d5d87..8da5e0c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" name = "rust_decimal" readme = "./README.md" repository = "https://github.com/paupino/rust-decimal" -version = "1.13.0" +version = "1.14.0" exclude = [ "tests/generated/*" ] [package.metadata.docs.rs] diff --git a/VERSION.md b/VERSION.md index 11356af5..c44a5a6d 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,5 +1,14 @@ # Version History +## 1.14.0 + +* Added `checked_exp` and `checked_norm_pdf` functions [#375](https://github.com/paupino/rust-decimal/pull/375). +* Fixes bug in division under certain circumstances whereby overflow would occur during rounding. [#377](https://github.com/paupino/rust-decimal/pull/377) +* Documentation improvements + +Thank you to [@falsetru](https://github.com/falsetru), [@schungx](https://github.com/schungx) and [@blasrodri](https://github.com/blasrodri) for your +help with this release! + ## 1.13.0 This is a minor update to the library providing a few new features and one breaking change (I'm not using semver properly here diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 09a096b4..e1569a46 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust_decimal_macros" -version = "1.13.0" +version = "1.14.0" authors = ["Paul Mason "] edition = "2018" description = "Shorthand macros to assist creating Decimal types." @@ -12,7 +12,7 @@ categories = ["science","data-structures"] license = "MIT" [dependencies] -rust_decimal = { path = "..", version = "1.13.0" } +rust_decimal = { path = "..", version = "1.14.0" } quote = "1.0" [features] diff --git a/src/decimal.rs b/src/decimal.rs index ce2d9f1a..98c526e3 100644 --- a/src/decimal.rs +++ b/src/decimal.rs @@ -297,7 +297,7 @@ impl Decimal { flags: flags & SCALE_MASK, } } else { - Decimal { lo, mid, hi, flags } + Decimal { flags, hi, lo, mid } } } @@ -1735,10 +1735,7 @@ impl ToPrimitive for Decimal { fn to_f64(&self) -> Option { if self.scale() == 0 { let integer = self.to_i64(); - match integer { - Some(i) => Some(i as f64), - None => None, - } + integer.map(|i| i as f64) } else { let sign: f64 = if self.is_sign_negative() { -1.0 } else { 1.0 }; let mut mantissa: u128 = self.lo.into(); diff --git a/tests/decimal_tests.rs b/tests/decimal_tests.rs index 8366545a..b39248ac 100644 --- a/tests/decimal_tests.rs +++ b/tests/decimal_tests.rs @@ -3431,6 +3431,13 @@ mod maths { } } + #[test] + #[should_panic(expected = "Exp overflowed")] + fn test_exp_expected_panic() { + let d = Decimal::from_str("-1024").unwrap(); + let _ = d.exp(); + } + #[test] fn test_norm_cdf() { let test_cases = &[