commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
c299d64fe2d2237c50126aca7275bbdc05cb4300 | David Weikersdorfer | 2025-07-27T21:25:01 | Fixed tests using legacy-ops feature. | diff --git a/tests/decimal_tests.rs b/tests/decimal_tests.rs
index 48bfa3b..dbb0899 100644
--- a/tests/decimal_tests.rs
+++ b/tests/decimal_tests.rs
@@ -3895,7 +3895,7 @@ mod maths {
(
"0.5",
"0.25",
- either!("0.8408964159265360661551317741", "0.84089641592... | 1 | 5 | 5 |
7b8d1cd25ea6f8d3a8f86b2a656692d310dff453 | David Weikersdorfer | 2025-07-27T17:27:41 | Improved exp
Improved algorithm to compute exp (and thus also pow) to not compute
x^i directly in the Taylor series as it quickly outgrows exp(x).
Instead the summand is grown with x/i. This also avoid using the
FACTORIAL table.
Additionally the loop avoids two unnecessary ops for the tolerance
check. In total perfor... | diff --git a/benches/lib_benches.rs b/benches/lib_benches.rs
index 5757c91..92cb4bc 100644
--- a/benches/lib_benches.rs
+++ b/benches/lib_benches.rs
@@ -288,6 +288,21 @@ mod maths {
});
}
+ #[bench]
+ fn exp_large(b: &mut ::test::Bencher) {
+ let samples = &[
+ Decimal::from_str(... | 3 | 74 | 40 |
c35a7af03733c802bf69b63a9b4c6cf2cbde47aa | Tony-Samuels | 2025-06-14T01:19:50 | Fix panic on 0.x parsing (#731)
* Fix panic on 0.x parsing
* Skip underscores to prevent rounding position errors
---------
Co-authored-by: Tony Samuels <tonysamuels@protonmail.com>
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/src/str.rs b/src/str.rs
index df12845..a322515 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -357,8 +357,20 @@ fn handle_full_128<const POINT: bool, const NEG: bool, const ROUND: bool>(
if ROUND {
// If it is an underscore at the rounding position we requ... | 1 | 30 | 2 |
7d462835434d1e9d7b1a73659b3cafd6e361244d | Tony-Samuels | 2025-06-14T01:19:50 | Fix panic on 0.x parsing (#731)
* Fix panic on 0.x parsing
* Skip underscores to prevent rounding position errors
---------
Co-authored-by: Tony Samuels <tonysamuels@protonmail.com>
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/src/str.rs b/src/str.rs
index 97ce733..fe360b5 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -357,8 +357,20 @@ fn handle_full_128<const POINT: bool, const NEG: bool, const ROUND: bool>(
if ROUND {
// If it is an underscore at the rounding position we requ... | 1 | 30 | 2 |
a393c1506726eeaa786be26a2ce935db5891990d | Aumetra Weisman | 2025-05-29T17:52:21 | `postgres` -> `postgres_backend` | diff --git a/Cargo.toml b/Cargo.toml
index 95f91b5..a45a62c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ bincode = { default-features = false, version = "1.0" }
bytes = { default-features = false, version = "1.0" }
criterion = { default-features = false, version = "0.5" }
csv = "1"
-diesel = { default-... | 1 | 2 | 2 |
e932f154d3a94cb7b97f4a60bada806862f0e7dd | Rollo Konig Brock | 2025-04-29T18:23:06 | Add a From<UnpackedDecimal> for decimal | diff --git a/src/decimal.rs b/src/decimal.rs
index 003a143..2b0930d 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -94,6 +94,21 @@ pub struct UnpackedDecimal {
pub lo: u32,
}
+impl From<UnpackedDecimal> for Decimal {
+ #[inline(always)]
+ fn from(value: UnpackedDecimal) -> Self {
+ let Unpacke... | 1 | 15 | 0 |
027b9913ae83fb8c30e7ce0a951a407c3f78b0ce | Tony Samuels | 2025-04-20T23:01:10 | chore: cargo fmt | diff --git a/benches/comparison.rs b/benches/comparison.rs
index d6bf29a..a1bc9f2 100644
--- a/benches/comparison.rs
+++ b/benches/comparison.rs
@@ -1,7 +1,7 @@
//! See how `rust-decimal` performs compared to native floating numbers.
use criterion::{
- black_box, criterion_group, criterion_main, measurement::Mea... | 10 | 27 | 67 |
534c08ea7abfb572d1086b7531896745ff46a3d5 | Tony Samuels | 2025-04-20T23:01:04 | chore: remove rand-0.8 support | diff --git a/Cargo.toml b/Cargo.toml
index bab89a3..95f91b5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,7 +28,6 @@ ndarray = { default-features = false, optional = true, version = "0.15.6" }
num-traits = { default-features = false, features = ["i128"], version = "0.2" }
postgres-types = { default-features = false... | 3 | 2 | 182 |
7298dac731e2b5351bcb6d4676e77b39f771a8c9 | Ivan | 2025-03-25T13:37:43 | use bit-wise OR for is_zero | diff --git a/src/decimal.rs b/src/decimal.rs
index f2f5e0e..50b311a 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -737,7 +737,7 @@ impl Decimal {
/// ```
#[must_use]
pub const fn is_zero(&self) -> bool {
- self.lo == 0 && self.mid == 0 && self.hi == 0
+ self.lo | self.mid | self.hi ==... | 1 | 1 | 1 |
cd8fc818acdf5cfb74b3188d7f5d4b59e5e2489c | Ivan | 2025-03-25T08:10:45 | more efficient is_zero check | diff --git a/src/decimal.rs b/src/decimal.rs
index f60e494..7a1a95d 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -718,8 +718,9 @@ impl Decimal {
/// assert!(num.is_zero());
/// ```
#[must_use]
+ #[inline]
pub const fn is_zero(&self) -> bool {
- self.lo == 0 && self.mid == 0 && self.... | 1 | 2 | 1 |
cf829e7922fdc6ddeec81bed4507a676cda8de7f | Paul Mason | 2025-03-22T15:12:52 | Bump revision | diff --git a/macros/Cargo.toml b/macros/Cargo.toml
index 4f088c7..2491bc7 100644
--- a/macros/Cargo.toml
+++ b/macros/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rust_decimal_macros"
-version = "1.37.0"
+version = "1.37.1"
authors = ["Paul Mason <paul@form1.co.nz>"]
edition = "2021"
description = "Shorthand macro... | 1 | 1 | 1 |
ffe9495d7734d8021718050f98e3f48f39c428b2 | Paul Mason | 2025-03-17T21:29:16 | Specify fixed version for macros dependency | diff --git a/Cargo.toml b/Cargo.toml
index fb198ee..d81e9d5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,7 +30,7 @@ postgres-types = { default-features = false, optional = true, version = "0.2" }
proptest = { default-features = false, optional = true, features = ["std"], version = "1.0" }
rand = { default-features... | 1 | 1 | 1 |
39fe37eca9d78aad65d9be2b1bdb74c2ad037c37 | Paul Mason | 2025-03-17T21:26:12 | Specify fixed version for macros dependency (#712) | diff --git a/Cargo.toml b/Cargo.toml
index 5c27276..fb198ee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,7 +30,7 @@ postgres-types = { default-features = false, optional = true, version = "0.2" }
proptest = { default-features = false, optional = true, features = ["std"], version = "1.0" }
rand = { default-features... | 1 | 1 | 1 |
f34cefc1127d358acbd6eb73c3bdd1de088e552a | Mike Cronce | 2025-03-05T19:19:54 | Reduce required mysql dependencies for diesel (#707)
* Cargo.toml: Only enable mysql_backend on diesel, not the whole mysql feature
* Cargo.toml: Add diesel with mysql feature enabled to dev-dependencies | diff --git a/Cargo.toml b/Cargo.toml
index 7e046d0..6ea2af9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,6 +41,7 @@ bincode = { default-features = false, version = "1.0" }
bytes = { default-features = false, version = "1.0" }
criterion = { default-features = false, version = "0.5" }
csv = "1"
+diesel = { default-... | 1 | 2 | 1 |
acffc436237b8d0561a96bd53ffed8a0435b2f25 | Paul Mason | 2025-02-23T01:15:38 | Clean up tests to use Ok/Err format (#703) | diff --git a/tests/decimal_tests.rs b/tests/decimal_tests.rs
index aa0e9db..b5a6cf8 100644
--- a/tests/decimal_tests.rs
+++ b/tests/decimal_tests.rs
@@ -3363,28 +3363,25 @@ fn it_can_parse_individual_parts() {
#[test]
fn it_can_parse_scientific_notation() {
let tests = &[
- ("9.7e-7", "0.00000097"),
- ... | 1 | 14 | 17 |
722af9f2c2829273f9c1b09e2fd989378f795cbc | Stephen Chung | 2025-02-21T04:25:33 | Fix panic when parsing improper scientific notation. (#700) | diff --git a/src/decimal.rs b/src/decimal.rs
index e828801..671ee0f 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -586,6 +586,9 @@ impl Decimal {
if let Some(stripped) = exp.strip_prefix('-') {
let exp: u32 = stripped.parse().map_err(|_| Error::from(ERROR_MESSAGE))?;
+ if exp > ... | 2 | 12 | 1 |
46fb4c3c517bc0c27cd534b65f9e8b57c24ba18e | Tony-Samuels | 2024-10-15T15:44:48 | Create pub constant Decimal::MAX_SCALE (#685) | diff --git a/src/constants.rs b/src/constants.rs
index 59f3366..a42940f 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -20,13 +20,13 @@ pub const SIGN_SHIFT: u32 = 31;
// to the byte boundary for simplicity.
pub const MAX_STR_BUFFER_SIZE: usize = 32;
-// The maximum supported precision
-pub const MAX_PRECI... | 15 | 78 | 77 |
9e3195bd6af001f6fbb92793b10da8251212899f | Olga Botvinnik | 2024-09-30T19:36:47 | maths is private: rust_decimal::maths::MathematicalOps -> rust_decimal::MathematicalOps | diff --git a/src/maths.rs b/src/maths.rs
index 9fbdb49..d07053c 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -49,7 +49,7 @@ const FACTORIAL: [Decimal; 28] = [
/// Trait exposing various mathematical operations that can be applied using a Decimal. This is only
/// present when the `maths` feature has been enabled... | 1 | 1 | 1 |
f14f1b647bfa1149a149fe540406aa7ecc3b1492 | Olga Botvinnik | 2024-09-30T19:32:29 | Add explanation of how to enable `maths` feature
Hello, | diff --git a/src/maths.rs b/src/maths.rs
index 6345d20..9fbdb49 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -48,7 +48,8 @@ const FACTORIAL: [Decimal; 28] = [
];
/// Trait exposing various mathematical operations that can be applied using a Decimal. This is only
-/// present when the `maths` feature has been ena... | 1 | 2 | 1 |
ca982d6603b849d1e9e0fe20e1ace7afd37cbc84 | Finn Bear | 2024-09-18T21:59:23 | Fix `f64` dec limit edge case (#678)
---
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/src/decimal.rs b/src/decimal.rs
index 3a1d787..5df67f3 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -2190,6 +2190,9 @@ fn base2_to_decimal(
exponent10 -= 1;
exponent5 += 1;
ops::array::shl1_internal(bits, 0);
+ } else if exponent10 * 2 > -exponent5 {
+ ... | 2 | 27 | 0 |
5bba9eb193fe5adc6ee97b96c33082e611296047 | Dylan DPC | 2024-09-10T15:18:07 | Update Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index a2c00f3..0e733d1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,7 +23,7 @@ arbitrary = { default-features = false, optional = true, version = "1.0" }
arrayvec = { default-features = false, version = "0.7" }
borsh = { default-features = false, features = ["derive", "unstable... | 1 | 1 | 1 |
f31e85a4bf6188edb479c2db13a39c7b123497b1 | Shashank Verma | 2024-08-17T18:45:09 | serde.rs: str_option: Fix type infer error (#670)
This error is caused by latest `arrayvec` crate which now implements 2 different versions `AsRef` traits. | diff --git a/src/serde.rs b/src/serde.rs
index 58245f4..c18e08e 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -269,7 +269,7 @@ pub mod str_option {
match *value {
Some(ref decimal) => {
let decimal = crate::str::to_str_internal(decimal, true, None);
- serializer.s... | 1 | 1 | 1 |
dd711dbee5081a243e8eae5b314ecd8b0505f3ef | Paul Mason | 2024-08-02T23:25:23 | Fixes issue with abs_sub whereby it was not returning the difference (#666) | diff --git a/src/decimal.rs b/src/decimal.rs
index 2388748..3a1d787 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1896,7 +1896,7 @@ impl Signed for Decimal {
if self <= other {
ZERO
} else {
- self.abs()
+ self - other
}
}
diff --git a/tests/de... | 2 | 3 | 3 |
6f8b0ae8570b33727a779da8bb81983c4bb58d68 | Maja Piechotka | 2024-07-11T16:21:07 | Replace filtery with a strategy for implementation of proptest::Arbitrary (#659)
* Replace filtery with a strategy for implementation of proptest::Arbitrary
* Modify std requirement to use core
---------
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/src/proptest.rs b/src/proptest.rs
index 4454d0a..3739bb6 100644
--- a/src/proptest.rs
+++ b/src/proptest.rs
@@ -1,24 +1,18 @@
use crate::Decimal;
+use core::ops::RangeInclusive;
use proptest::arbitrary::{Arbitrary, StrategyFor};
use proptest::prelude::*;
-use proptest::strategy::FilterMap;
+use propte... | 1 | 7 | 13 |
b2d00c1373471a13e2aafdb33d55b4bbfded63af | Paul Mason | 2024-07-11T15:36:50 | Bump macro version to 1.35 (#661) | diff --git a/macros/Cargo.toml b/macros/Cargo.toml
index 16085bb..25b037f 100644
--- a/macros/Cargo.toml
+++ b/macros/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rust_decimal_macros"
-version = "1.34.2"
+version = "1.35.0"
authors = ["Paul Mason <paul@form1.co.nz>"]
edition = "2021"
description = "Shorthand macro... | 1 | 1 | 1 |
6f7d295cd82571429064132265f907131841c60f | Ben Schulz | 2024-04-11T15:56:27 | Fix negation with overflow (#657)
* Fix negation with overflow
* Extend scope of tests to remove blindness
---------
Co-authored-by: Paul Mason <paul@salsa.dev> | diff --git a/src/decimal.rs b/src/decimal.rs
index 45f5661..20dd9c0 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1990,7 +1990,7 @@ impl FromPrimitive for Decimal {
unsigned = n as u128;
flags = 0;
} else {
- unsigned = -n as u128;
+ unsigned = n.unsigned_... | 2 | 20 | 7 |
913dc5bc13dd20f9977f5a5591da0465d4db641a | Luke Osborne | 2024-03-29T22:55:01 | Fix FromSql for Postgres Numeric NaNs (#656)
* Fix FromSql for Postgres Numeric NaNs
This fixes a bug where from_sql was converting Numeric::NaN to 0
rather than returning an error.
It also returns a more descriptive error message when from_sql is called
with Numeric Infinity and -Infinity, which are also not ... | diff --git a/src/postgres/driver.rs b/src/postgres/driver.rs
index 9e761bf..6bbab11 100644
--- a/src/postgres/driver.rs
+++ b/src/postgres/driver.rs
@@ -1,9 +1,16 @@
+use crate::error::Error;
use crate::postgres::common::*;
use crate::Decimal;
use bytes::{BufMut, BytesMut};
use postgres_types::{to_sql_checked, From... | 2 | 53 | 2 |
03776504ffa837067f96e25d7b02768be5e2060d | Paul Mason | 2024-03-27T01:19:28 | Fixes issue with overflow for Postgres (#653) | diff --git a/src/postgres/common.rs b/src/postgres/common.rs
index 485a259..e0fd9d9 100644
--- a/src/postgres/common.rs
+++ b/src/postgres/common.rs
@@ -31,14 +31,14 @@ pub(in crate::postgres) struct PostgresDecimal<D> {
}
impl Decimal {
- pub(in crate::postgres) fn from_postgres<D: ExactSizeIterator<Item = u16>... | 3 | 42 | 14 |
3360143d13003677c6dbb1276eb2bc24424c3bfe | Moritz von Göwels | 2024-03-07T17:15:43 | Remove feature-guarded dependencies on 'postgres' and 'tokio_postgres' (#651)
...and replace with dependency on 'postgres_types' | diff --git a/Cargo.toml b/Cargo.toml
index b99a14c..72f302b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,7 @@ diesel1 = { default-features = false, optional = true, package = "diesel", versi
diesel2 = { default-features = false, optional = true, package = "diesel", version = "2.1" }
ndarray = { default-featu... | 2 | 6 | 4 |
1a119c73e268783c698b820712a79d9a16179e5b | Paul Mason | 2024-02-10T20:21:46 | Prevent scale of 29 from postgresql hydration (#647) | diff --git a/src/postgres/common.rs b/src/postgres/common.rs
index 3922b7d..485a259 100644
--- a/src/postgres/common.rs
+++ b/src/postgres/common.rs
@@ -78,7 +78,7 @@ impl Decimal {
result.set_sign_negative(neg);
// Rescale to the postgres value, automatically rounding as needed.
- result.res... | 2 | 38 | 1 |
aa2c3d3be8f7b2c96480f4b787240d531e3cfb93 | Paul Mason | 2024-01-13T18:04:22 | Fixes error handling when second decimal place at tail position (#636)
* Fixes error handling when second decimal place at tail position
* Added further bounds tests | diff --git a/src/str.rs b/src/str.rs
index 9454573..b381b2a 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -213,6 +213,14 @@ fn dispatch_next<const POINT: bool, const NEG: bool, const HAS: bool, const BIG:
}
}
+/// Dispatch the next non-digit byte:
+///
+/// * POINT - a decimal point has been seen
+/// * NEG - we'... | 1 | 108 | 11 |
10ee2eefba5f473fb67e9b0f625fb6a07cbc7d4b | Rob Ede | 2024-01-09T23:18:43 | Auto-document feature guarded items (#634)
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/Cargo.toml b/Cargo.toml
index d1c1be9..5bf7199 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,7 @@ version = "1.33.1"
[package.metadata.docs.rs]
all-features = true
+rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
arbitrary = { default-features = false, optional = true, version = "1.0" }
d... | 2 | 2 | 0 |
c3802dba39fc467669030ee279fad22f1e44912f | Paul Mason | 2023-11-16T23:08:09 | Fixes precision issue with to_f64 with some numbers without fractions (#625)
* Fixes precision issue with to_f64 with some numbers without fractions
* Sign should not be applied to early for to_f64 | diff --git a/src/decimal.rs b/src/decimal.rs
index e057d4f..45f5661 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -2354,7 +2354,7 @@ impl ToPrimitive for Decimal {
let integer = self.to_i128();
integer.map(|i| i as f64)
} else {
- let sign: f64 = if self.is_sign_negat... | 3 | 44 | 5 |
6cfccf3980fe204ecd333370fefb596d1b5127ae | gaius | 2023-11-14T00:57:48 | deserializes empty string into None Option (#607)
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/src/serde.rs b/src/serde.rs
index c423772..993b008 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -426,7 +426,22 @@ impl<'de> serde::de::Visitor<'de> for OptionDecimalStrVisitor {
where
D: serde::de::Deserializer<'de>,
{
- d.deserialize_str(DecimalVisitor).map(Some)
+ d.de... | 1 | 22 | 1 |
ede308d407291759f73b9eb5aabc165a768b7e8b | Paul Mason | 2023-11-13T15:38:44 | Upgrade Borsh to resolve vulnerability (#621)
* Update to 1.1 borsh
* Fixes Borsh upgrade
---------
Co-authored-by: John Barker <dev@j16r.net> | diff --git a/Cargo.toml b/Cargo.toml
index 5373244..7d160f5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,7 @@ all-features = true
[dependencies]
arbitrary = { default-features = false, optional = true, version = "1.0" }
arrayvec = { default-features = false, version = "0.7" }
-borsh = { default-features = f... | 1 | 1 | 1 |
1686b69fb6fc43018397cec69f99023ee6081d08 | Paul Mason | 2023-11-10T17:34:35 | Fixes issue whereby scale 29 is required however is optimized away (#619)
* Fixes issue whereby scale 29 is required however is optimized away
* Disable test for legacy ops | diff --git a/src/ops/add.rs b/src/ops/add.rs
index 52ba675..9a0c5bd 100644
--- a/src/ops/add.rs
+++ b/src/ops/add.rs
@@ -1,4 +1,6 @@
-use crate::constants::{MAX_I32_SCALE, POWERS_10, SCALE_MASK, SCALE_SHIFT, SIGN_MASK, U32_MASK, U32_MAX};
+use crate::constants::{
+ MAX_I32_SCALE, MAX_PRECISION_U32, POWERS_10, SCALE_... | 2 | 38 | 2 |
951512d003a4b65724d6074a15630534994b40e6 | Paul Mason | 2023-08-23T14:49:28 | Fixes issue with is_integer failing on decimal bounds (#605) | diff --git a/src/decimal.rs b/src/decimal.rs
index 191d31f..e057d4f 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -768,7 +768,7 @@ impl Decimal {
let mut scale = scale;
while scale > 0 {
let remainder = if scale > 9 {
- scale -= 10;
+ scale -= 9;
... | 2 | 5 | 1 |
a6d5caf0328842e612787b30239abefdeda48951 | Uli Schlachter | 2023-08-18T19:21:49 | Drop unnecessary byteorder dependency (#603) | diff --git a/Cargo.toml b/Cargo.toml
index 4c2ff87..c1ebd23 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,6 @@ all-features = true
arbitrary = { default-features = false, optional = true, version = "1.0" }
arrayvec = { default-features = false, version = "0.7" }
borsh = { default-features = false, optional =... | 2 | 16 | 12 |
29d3e2e8b789051f209438261cb4ef824cddd2a9 | Paul Mason | 2023-07-29T23:40:14 | Specify version on macro dependency | diff --git a/macros/Cargo.toml b/macros/Cargo.toml
index 03d5d7b..3dc1302 100644
--- a/macros/Cargo.toml
+++ b/macros/Cargo.toml
@@ -12,7 +12,7 @@ categories = ["science","data-structures"]
license = "MIT"
[dependencies]
-rust_decimal = { path = "..", default-features = false }
+rust_decimal = { path = "..", versio... | 1 | 1 | 1 |
091d715e60319d41b5f58e2377c7c00de14be3c8 | Mikhail Katychev | 2023-07-17T00:49:13 | added new rkyv (#597) | diff --git a/Cargo.toml b/Cargo.toml
index 429f101..b6a01c5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,6 @@ all-features = true
arbitrary = { default-features = false, optional = true, version = "1.0" }
arrayvec = { default-features = false, version = "0.7" }
borsh = { default-features = false, optional =... | 2 | 4 | 5 |
deeb242f3832e15833bf21791a53ecf79234553f | Paul Mason | 2023-07-17T00:05:17 | Fixes issue with truncating implicitly rounding in some cases (#600) | diff --git a/src/ops/array.rs b/src/ops/array.rs
index 2840e4b..ed3fce6 100644
--- a/src/ops/array.rs
+++ b/src/ops/array.rs
@@ -2,8 +2,13 @@ use crate::constants::{MAX_PRECISION_U32, POWERS_10, U32_MASK};
/// Rescales the given decimal to new scale.
/// e.g. with 1.23 and new scale 3 rescale the value to 1.230
-#[... | 2 | 78 | 38 |
2565a955523abf1a135c8cc31cdae02073d096a7 | Paul Mason | 2023-05-16T03:28:43 | Implement is_integer function (#591) | diff --git a/src/decimal.rs b/src/decimal.rs
index 2a979e3..8730d2c 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -742,6 +742,46 @@ impl Decimal {
self.lo == 0 && self.mid == 0 && self.hi == 0
}
+ /// Returns true if this Decimal number has zero fractional part (is equal to an integer)
+ ///... | 3 | 71 | 12 |
4b505b1bcd6f0917ee1de9bf7bb835b1558647db | Paul Mason | 2023-03-25T00:06:38 | Fixes QUARTER_PI causing a stack overflow for cos/sin (#585) | diff --git a/src/maths.rs b/src/maths.rs
index c402453..7cde970 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -549,7 +549,7 @@ impl MathematicalOps for Decimal {
// -Sin(x-π)
return (self - Decimal::PI).checked_sin().map(|x| -x);
}
- if self >= &Decimal::QUARTER_PI {
+ ... | 2 | 5 | 2 |
d6e5ad45e73af062b0b68ff72fa65b5b0b88d8c4 | Paul Mason | 2023-03-07T02:57:12 | Refactor truncate to allow for a shared code path (#578) | diff --git a/src/decimal.rs b/src/decimal.rs
index fb6da6b..19419a6 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -699,7 +699,7 @@ impl Decimal {
#[inline]
#[must_use]
pub const fn scale(&self) -> u32 {
- ((self.flags & SCALE_MASK) >> SCALE_SHIFT) as u32
+ (self.flags & SCALE_MASK) >>... | 4 | 67 | 28 |
e4b5c514f2b5dd052335e2f1bdf4736a1370aa2e | Caio | 2023-03-07T02:08:01 | Introduce `trunc_with_scale` (#576) | diff --git a/src/decimal.rs b/src/decimal.rs
index b670f76..fb6da6b 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1050,6 +1050,21 @@ impl Decimal {
}
}
+ /// Returns a new `Decimal` with the fractional portion delimited by `scale`.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # u... | 2 | 38 | 0 |
c205456643a5f831396c2e98caa7fc91f96363bc | jon-chuang | 2023-02-09T16:49:48 | fix: decimal round_dp on zero with too large dp (#575)
Co-authored-by: jon-chuang <jon-chuang@users.noreply.github.com> | diff --git a/src/decimal.rs b/src/decimal.rs
index e98f7b4..b670f76 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1274,6 +1274,14 @@ impl Decimal {
/// ```
#[must_use]
pub fn round_dp_with_strategy(&self, dp: u32, strategy: RoundingStrategy) -> Decimal {
+ let old_scale = self.scale();
+
+ ... | 2 | 17 | 8 |
7935895faf7fd4ac65aac29b405792dc526e4cd8 | Paul Mason | 2023-02-04T20:12:21 | Remove debug statements and add lint (#571) | diff --git a/src/lib.rs b/src/lib.rs
index 7945758..84239fd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,6 @@
#![doc = include_str!(concat!(env!("OUT_DIR"), "/README-lib.md"))]
#![forbid(unsafe_code)]
+#![deny(clippy::print_stdout, clippy::print_stderr)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crat... | 2 | 1 | 3 |
bc8b53a7ca697945642ebe3a44f38d9cd6f0bd83 | Paul Mason | 2023-01-13T23:45:25 | Fixes rescale internal allowing zeros to scale greater than the maximum possible precision (#566) | diff --git a/src/ops/array.rs b/src/ops/array.rs
index 651ba55..2ab58b4 100644
--- a/src/ops/array.rs
+++ b/src/ops/array.rs
@@ -1,4 +1,4 @@
-use crate::constants::{POWERS_10, U32_MASK};
+use crate::constants::{MAX_PRECISION_U32, POWERS_10, U32_MASK};
/// Rescales the given decimal to new scale.
/// e.g. with 1.23 ... | 2 | 42 | 15 |
2da7a0d13427a29b7ca1025db95f3cff3a89f2ce | Paul Mason | 2023-01-13T00:59:05 | Explicit string (de)serialize for optional serde-with-str values (#565) | diff --git a/src/serde.rs b/src/serde.rs
index fa53c74..e768a4a 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -259,7 +259,7 @@ pub mod str_option {
where
D: serde::de::Deserializer<'de>,
{
- deserializer.deserialize_option(OptionDecimalVisitor)
+ deserializer.deserialize_option(Option... | 1 | 58 | 3 |
69c1e7f067d501f00bb57296da94cd8319e750bb | Caio | 2022-12-08T18:11:39 | Implement `TryFrom<&str>` for `Decimal` (#560) | diff --git a/src/decimal.rs b/src/decimal.rs
index 85fb188..e98f7b4 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1770,7 +1770,7 @@ impl_try_from_decimal!(u128, Decimal::to_u128, integer_docs!(true));
// See https://github.com/rust-lang/rustfmt/issues/5062 for more information.
#[rustfmt::skip]
macro_rules! i... | 2 | 11 | 4 |
a623a5f74e592205a5bbc4248709440a21bb0528 | Paul Mason | 2022-11-24T21:44:37 | Better testing of optional serde (#558) | diff --git a/src/serde.rs b/src/serde.rs
index 56404dd..fa53c74 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -386,12 +386,22 @@ impl<'de> serde::de::Visitor<'de> for OptionDecimalVisitor {
Ok(None)
}
+ #[cfg(all(feature = "serde-str", feature = "serde-float"))]
fn visit_some<D>(self, d: D) ->... | 1 | 18 | 0 |
11be8cd77a6d4950dac301d87f7fa1d372e90daf | Christopher Durham | 2022-11-24T21:07:26 | Fix rounding mantissa overflow (#541)
* fix rounding of near mantissa overflow part 1
* fix rounding of near mantissa overflow part 2
* reuse maybe_round in both paths
* Make tests more readable with digit separators
* Fixes test failure due to underscores
* Fixes code formatting
Co-authored-by: Paul Mason <pa... | diff --git a/src/str.rs b/src/str.rs
index 8df3423..f3b89d3 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -336,18 +336,10 @@ fn handle_full_128<const POINT: bool, const NEG: bool, const ROUND: bool>(
}
if ROUND {
- if digit >= 5 {
- data += 1;
... | 2 | 68 | 18 |
d013f44a31d8cc89c084a4a55f90505b93feac9f | Paul Mason | 2022-11-24T19:45:28 | Refactor scientific precision for readability (#557) | diff --git a/src/str.rs b/src/str.rs
index bfe3ca8..8df3423 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -102,30 +102,49 @@ pub(crate) fn fmt_scientific_notation(
// point in the right place and adjust the exponent accordingly.
let len = chars.len();
- let precision = f.precision().unwrap_or(0);
let ... | 1 | 52 | 33 |
31dad0a99a1253f8e689abf295ec5d9246627dbc | Nick Senger | 2022-11-24T19:26:08 | Support precision in `fmt_scientific_notation` (#555)
* Support precision in `fmt_scientific_notation`
* fix: move test
* fmt: collapse if else | diff --git a/src/str.rs b/src/str.rs
index d8e68e4..bfe3ca8 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -102,16 +102,30 @@ pub(crate) fn fmt_scientific_notation(
// point in the right place and adjust the exponent accordingly.
let len = chars.len();
+ let precision = f.precision().unwrap_or(0);
let ... | 2 | 107 | 4 |
4b7176177cfd3938cecb59d9358667a8a2d4ab6d | icy-ux | 2022-08-31T00:57:40 | add rkyv Clone/Copy derivations (#539)
Co-authored-by: icyfestive <> | diff --git a/src/decimal.rs b/src/decimal.rs
index 7148b54..c9e3604 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -121,7 +121,7 @@ pub struct UnpackedDecimal {
feature = "rkyv",
derive(Archive, Deserialize, Serialize),
archive(compare(PartialEq)),
- archive_attr(derive(Debug))
+ archive_attr(... | 1 | 1 | 1 |
afd41f7c3f1de2356abf7db4ba43bbb413e92b13 | Paul Mason | 2022-07-18T17:01:58 | Fixes silent overflow when parsing Decimal::MAX with a fractional component (#530) | diff --git a/src/str.rs b/src/str.rs
index f214ef1..d8e68e4 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -305,6 +305,11 @@ fn handle_full_128<const POINT: bool, const NEG: bool, const ROUND: bool>(
if ROUND {
if digit >= 5 {
data += 1;
+
+ ... | 1 | 14 | 0 |
aff1b9f3453e3d3af33036179a42da41b4a03228 | Caio | 2022-06-27T21:45:38 | Implement `Product` (#525) | diff --git a/benches/lib_benches.rs b/benches/lib_benches.rs
index be6356a..5757c91 100644
--- a/benches/lib_benches.rs
+++ b/benches/lib_benches.rs
@@ -126,6 +126,14 @@ fn iterator_individual(b: &mut ::test::Bencher) {
});
}
+#[bench]
+fn iterator_product(b: &mut ::test::Bencher) {
+ b.iter(|| {
+ le... | 3 | 46 | 4 |
98d8057788a4d2572805e31555c8ff5efb9db5f7 | Caio | 2022-05-18T16:34:24 | Remove unused dependencies (#516) | diff --git a/Cargo.toml b/Cargo.toml
index 4ba460b..34ad44f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,16 +36,16 @@ serde_json = { default-features = false, optional = true, version = "1.0" }
tokio-postgres = { default-features = false, optional = true, version = "0.7" }
[dev-dependencies]
-bincode = "1.3"
-by... | 1 | 5 | 5 |
7a95035ba3d336d254ff9a697c3f18c332687328 | Paul Mason | 2022-03-27T00:04:53 | Fixes issue with workspace build always including default (#503) | diff --git a/macros/Cargo.toml b/macros/Cargo.toml
index b0d7181..799bc2d 100644
--- a/macros/Cargo.toml
+++ b/macros/Cargo.toml
@@ -12,7 +12,7 @@ categories = ["science","data-structures"]
license = "MIT"
[dependencies]
-rust_decimal = { path = "..", version = "1.23.1" }
+rust_decimal = { path = "..", version = "1... | 3 | 10 | 3 |
0971386d9a52cbca9de0c1a3157398cae8dc2493 | Paul Mason | 2022-03-26T22:41:03 | Fixes no_std compile by avoiding to_string (#501) | diff --git a/src/decimal.rs b/src/decimal.rs
index 63c14b7..e2a5aa0 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1725,7 +1725,7 @@ macro_rules! impl_try_from_decimal {
#[inline]
fn try_from(t: Decimal) -> Result<Self, Error> {
- $conversion_fn(&t).ok_or_else(|| Error::... | 1 | 2 | 2 |
13735d63a3c19f10242203aec28b815f100abff6 | Paul Mason | 2022-03-26T16:34:56 | Remove keyword since crates.io only supports 5 | diff --git a/Cargo.toml b/Cargo.toml
index a7f69f9..8598f95 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ description = "Decimal number implementation written in pure Rust suitable for f
documentation = "https://docs.rs/rust_decimal/"
edition = "2018"
exclude = [ "tests/generated/*" ]
-keywords = ["deci... | 1 | 1 | 1 |
88125c81cb47ad4232292760b65db98ab15b17d2 | jnitard | 2022-03-24T21:16:34 | Implement BorshSchema (#498) | diff --git a/src/decimal.rs b/src/decimal.rs
index 30b0859..63c14b7 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -97,7 +97,10 @@ pub struct UnpackedDecimal {
#[derive(Clone, Copy)]
#[cfg_attr(feature = "diesel", derive(FromSqlRow, AsExpression), sql_type = "Numeric")]
#[cfg_attr(feature = "c-repr", repr(C))]
... | 2 | 7 | 1 |
2de2a6dd2f385e98c4019ebe38b5c6de5fef6cba | Paul Mason | 2022-03-19T19:21:25 | Fix Decimal::to_i64 for I64::MIN (#496)
Co-authored-by: Paul Mason <paul@paulmason.me>
Co-authored-by: Arthur Silva <arthurprs@gmail.com> | diff --git a/src/decimal.rs b/src/decimal.rs
index 5c0666f..30b0859 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -2203,15 +2203,26 @@ fn base2_to_decimal(
impl ToPrimitive for Decimal {
fn to_i64(&self) -> Option<i64> {
let d = self.trunc();
- // Quick overflow check
- if d.hi != 0 |... | 2 | 35 | 13 |
168fa67932b88bf65d5fa6c84612f02f052e6ec5 | Manuel Bärenz | 2022-03-18T17:43:36 | Add TryFrom impls to primitive types (#493)
Fixes #492
Co-authored-by: Manuel Bärenz <m.baerenz@sonnen.de>
Co-authored-by: Paul Mason <paul@paulmason.me> | diff --git a/src/decimal.rs b/src/decimal.rs
index 2b9b8ba..5c0666f 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1694,8 +1694,84 @@ const fn flags(neg: bool, scale: u32) -> u32 {
(scale << SCALE_SHIFT) | ((neg as u32) << SIGN_SHIFT)
}
+macro_rules! integer_docs {
+ ( true ) => {
+ " by truncat... | 3 | 88 | 32 |
4b97ec42c7fa003cd1ea2c3beb8a2871f1963a27 | Manuel Bärenz | 2022-03-17T16:11:14 | Inv implementation for Decimal (#495)
Fixes #494
Co-authored-by: Manuel Bärenz <m.baerenz@sonnen.de> | diff --git a/src/arithmetic_impls.rs b/src/arithmetic_impls.rs
index c51b6eb..81cfa30 100644
--- a/src/arithmetic_impls.rs
+++ b/src/arithmetic_impls.rs
@@ -3,7 +3,7 @@
use crate::{decimal::CalculationResult, ops, Decimal};
use core::ops::{Add, Div, Mul, Rem, Sub};
-use num_traits::{CheckedAdd, CheckedDiv, CheckedM... | 2 | 19 | 5 |
34060a2a27dfecd903c393cb5d478d45b5adf971 | Paul Mason | 2022-02-20T17:42:17 | Additional serde test for arbitrary precision (#487) | diff --git a/src/serde.rs b/src/serde.rs
index 0ef8bc8..0d0d7a8 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -509,6 +509,19 @@ mod test {
assert_eq!(&serde_json::to_string(&value).unwrap(), r#"{"value":123.400}"#);
}
+ #[test]
+ #[cfg(feature = "serde-with-arbitrary-precision")]
+ fn with_ar... | 1 | 13 | 0 |
cb8c8283a24bede616dd8b372ff634a0003ef780 | Paul Mason | 2022-02-20T00:47:37 | Fix for serde-with-str whereby it was utilizing deserialize_any instead of deserialize_str (#484) | diff --git a/src/serde.rs b/src/serde.rs
index 2f79d0c..0ef8bc8 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -106,27 +106,21 @@ pub mod float {
/// ```
#[cfg(feature = "serde-with-str")]
pub mod str {
- use crate::constants::MAX_STR_BUFFER_SIZE;
-
use super::*;
- use arrayvec::ArrayString;
- use cor... | 1 | 33 | 9 |
1d525897a6bf41b79dcc0ab38f28d6f890edc105 | Paul Mason | 2022-02-19T01:58:34 | Add missing must_use to is_sign_negative and unpack (#482) | diff --git a/src/decimal.rs b/src/decimal.rs
index be46592..2b9b8ba 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -953,6 +953,7 @@ impl Decimal {
/// assert_eq!(false, Decimal::new(1, 0).is_sign_negative());
/// ```
#[inline(always)]
+ #[must_use]
pub const fn is_sign_negative(&self) -> boo... | 1 | 2 | 0 |
497a1ef837146bafacbc93712b1dc3518ac7c415 | Paul Mason | 2022-02-18T03:35:49 | Add explicit documentation for Default (#481) | diff --git a/src/decimal.rs b/src/decimal.rs
index a01c23f..be46592 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1672,6 +1672,9 @@ impl Decimal {
}
impl Default for Decimal {
+ /// Returns the default value for a `Decimal` (equivalent to `Decimal::ZERO`). [Read more]
+ ///
+ /// [Read more]: core::... | 1 | 3 | 0 |
fc3c8058e861e1bdb395af1cd014cb94f910fec3 | Paul Mason | 2022-02-18T03:04:42 | Version sync tests for ensuring documentation up to date (#479) | diff --git a/Cargo.toml b/Cargo.toml
index fe18431..23e81fc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -45,6 +45,7 @@ rust_decimal_macros = { path = "macros" } # This should be ok since it's just fo
serde = { default-features = false, features = ["derive"], version = "1.0" }
serde_json = "1.0"
tokio = { features = ... | 2 | 10 | 0 |
99c615e91cf27a816071ffd91b0058d8e3419e56 | Paul Mason | 2022-02-02T22:20:22 | Fix up some inaccurate documentation (#476) | diff --git a/src/serde.rs b/src/serde.rs
index f277df4..2f79d0c 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -4,7 +4,7 @@ use core::{fmt, str::FromStr};
use num_traits::FromPrimitive;
use serde::{self, de::Unexpected};
-/// Serialize Decimals as arbitrary precision numbers in JSON.
+/// Serialize/deserialize Dec... | 1 | 3 | 3 |
8d4e3c3548b42c00dfd5f2002eac1da72bbdd028 | Paul Mason | 2022-01-31T20:15:53 | Minor fixes to allow for serde examples to be tested in readme (#474) | diff --git a/build.rs b/build.rs
index 09e4952..f8f84f6 100644
--- a/build.rs
+++ b/build.rs
@@ -16,6 +16,7 @@ fn prepare(readme: &str) -> String {
let mut cleaned = String::new();
let mut body = false;
let mut feature_section = false;
+ let mut feature = String::new();
for line in readme.lines()... | 1 | 9 | 1 |
adcde2021034aa9b3247f89be83951c9a692625f | Paul Mason | 2022-01-27T16:31:33 | Fixes issue with bordering log10 values < 1 (#469) | diff --git a/src/maths.rs b/src/maths.rs
index 35268cc..e512f92 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -450,6 +450,7 @@ impl MathematicalOps for Decimal {
if self.is_one() {
return Some(Decimal::ZERO);
}
+
// This uses a very basic method for calculating log10. We know t... | 2 | 21 | 4 |
b38797bff70f45a5481db5c04070cbfa45bc5485 | Paul Mason | 2022-01-19T03:04:17 | Minor documentation modifications (#467) | diff --git a/src/arithmetic_impls.rs b/src/arithmetic_impls.rs
index 7ccba57..c51b6eb 100644
--- a/src/arithmetic_impls.rs
+++ b/src/arithmetic_impls.rs
@@ -28,28 +28,15 @@ macro_rules! impl_checked {
};
}
-macro_rules! impl_checked_and_saturating {
- (
- $checked_long:literal,
- $checked_short... | 2 | 32 | 22 |
abc0279a063b0f83ea93eb6e5c3ab220f9a92c93 | Paul Mason | 2022-01-17T16:37:41 | Rescale tests modified to clarify behavior (#465)
* rescale tests modified to clarify behavior
* Modify documentation further | diff --git a/src/decimal.rs b/src/decimal.rs
index b8523b2..f3abc37 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -613,17 +613,18 @@ impl Decimal {
Ok(())
}
- /// Modifies the `Decimal` to the given scale, attempting to do so without changing the
+ /// Modifies the `Decimal` towards the desi... | 2 | 37 | 23 |
30eb444ab827c8dab9e686aa79fa1f32565caea3 | Caio | 2022-01-10T23:28:07 | Various maintenance tasks (#460)
* Const generics to reduce duplicate code for array ops
* Replace default op with `wrapping_sub` to better communicate intentions
* Avoid additional heap allocation for serde serialization
* Fixes documentation test
* Clippy cleanup | diff --git a/src/constants.rs b/src/constants.rs
index 2600f4f..59f3366 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -9,7 +9,7 @@ pub const UNSIGN_MASK: u32 = 0x4FFF_FFFF;
// contain a value between 0 and 28 inclusive.
pub const SCALE_MASK: u32 = 0x00FF_0000;
pub const U8_MASK: u32 = 0x0000_00FF;
-pub con... | 7 | 63 | 45 |
fca96a533e675e9953addcaeaa836d556786ff5e | Paul Mason | 2022-01-08T19:05:34 | Optimize `parse_str_radix_10` (#456)
* Fix `from_str` overflow rounding issue
The culprit is where `maybe_round` prevented the number from overflowing
, and ended up returning an `Ok` in the end. The fix is to round a
number only after we have passed the decimal point.
* Remove coeff ArrayVec from `parse_str_radix_1... | diff --git a/src/constants.rs b/src/constants.rs
index fcff4d9..2600f4f 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -65,3 +65,8 @@ pub const MAX_I32_SCALE: i32 = 9;
pub const MAX_I64_SCALE: u32 = 19;
#[cfg(not(feature = "legacy-ops"))]
pub const U32_MAX: u64 = u32::MAX as u64;
+
+// Determines potential ... | 5 | 423 | 135 |
005b7be55b8b5b182a99fbcd618239c3001c9cea | Luke Brown | 2022-01-05T02:49:15 | RoundingStrategy::MidpointTowardZero doc fix (#458) | diff --git a/src/decimal.rs b/src/decimal.rs
index 55c71d8..7d094f4 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -125,7 +125,7 @@ pub enum RoundingStrategy {
/// is away from zero. e.g. 6.4 -> 6, 6.5 -> 7, -6.5 -> -7
MidpointAwayFromZero,
/// When a number is halfway between two others, it is roun... | 1 | 1 | 1 |
3e771d908d1d4875e78a09505c47bda5fb14fa6c | James Collins | 2021-12-20T16:53:31 | added num_traits `Signed` to prelude (#450) | diff --git a/src/lib.rs b/src/lib.rs
index 6c90b0b..1b2bb0b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -203,7 +203,7 @@ pub mod prelude {
pub use crate::maths::MathematicalOps;
pub use crate::{Decimal, RoundingStrategy};
pub use core::str::FromStr;
- pub use num_traits::{FromPrimitive, One, ToPrimiti... | 1 | 1 | 1 |
2f2d0fbe46aa5ccabfc7adedb80a4a7c1adf6cb5 | Anatoliy Samara | 2021-11-25T21:19:19 | Fixes integer handling in Decimal::to_f64 by expanding range (#443) | diff --git a/src/decimal.rs b/src/decimal.rs
index 4da9868..55c71d8 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -2090,7 +2090,10 @@ impl ToPrimitive for Decimal {
fn to_f64(&self) -> Option<f64> {
if self.scale() == 0 {
- let integer = self.to_i64();
+ // If scale is zero, ... | 2 | 10 | 5 |
d762427801ed7b7aa1a86f53af21fe9575c04d4a | Paul Mason | 2021-10-21T18:04:05 | Feature: Retain excess precision during float conversions (#441) | diff --git a/src/decimal.rs b/src/decimal.rs
index 3a80431..4da9868 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1403,140 +1403,46 @@ impl Decimal {
[self.lo, self.mid, self.hi, 0]
}
- fn base2_to_decimal(bits: &mut [u32; 3], exponent2: i32, positive: bool, is64: bool) -> Option<Self> {
- ... | 2 | 381 | 311 |
5ff1538b5a0b713819eaf151a8e65f0d9a403d0d | Paul Mason | 2021-10-20T16:53:56 | Fixes significant figure calcs for small numbers (#440) | diff --git a/src/decimal.rs b/src/decimal.rs
index 94a35d2..3a80431 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1213,6 +1213,9 @@ impl Decimal {
/// assert_eq!(value.round_sf(6), Some(Decimal::from_str("305.459").unwrap()));
/// assert_eq!(value.round_sf(7), Some(Decimal::from_str("305.4590").unwrap(... | 2 | 14 | 9 |
980c98704ad337f107983d9e784f53e482a27dc6 | Paul Mason | 2021-10-15T23:31:03 | Auto rounding of scales 29, 30 and 31 for deserialization (#436) | diff --git a/src/decimal.rs b/src/decimal.rs
index afd4c70..94a35d2 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -697,17 +697,29 @@ impl Decimal {
// Bits 16-23: Contains "e", a value between 0-28 that indicates the scale
// Bits 24-30: unused
// Bit 31: the sign of the Decimal v... | 3 | 59 | 14 |
c74bd40701cce99b264af6b9af2e66d0f66251f1 | Paul Mason | 2021-10-15T21:25:57 | Fixes Display Overflow issue when using precision greater than 30 (#433)
* Prevent Display implementation overflow
* Branch display logic to allow precision greater than 28 to be used
* Bind deserialize to a maximum precision
Co-authored-by: Caio <c410.f3r@gmail.com> | diff --git a/src/constants.rs b/src/constants.rs
index ec62ffe..fcff4d9 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -21,9 +21,12 @@ pub const SIGN_SHIFT: u32 = 31;
pub const MAX_STR_BUFFER_SIZE: usize = 32;
// The maximum supported precision
-pub const MAX_PRECISION: u32 = 28;
+pub const MAX_PRECISION: ... | 9 | 104 | 43 |
46409c41a7e37026aa48d09ea63cf37256d7325a | Paul Mason | 2021-08-28T03:36:50 | Clean up some lazy styling | diff --git a/src/db.rs b/src/db.rs
index 3f79669..d2be8a8 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -61,9 +61,8 @@ impl Decimal {
}
// adding fractional part
if fractionals_part_count > 0 {
- let dec: Vec<_> = digits.into_iter().collect();
let start_fractionals = if we... | 3 | 9 | 25 |
eda3f76a520a47fb925ba0a8eb1be2c8b54ee04a | Paul Mason | 2021-08-28T03:17:21 | Add in round_sf_with_strategy to mirror round_dp | diff --git a/src/decimal.rs b/src/decimal.rs
index 80517d1..8d1b7e2 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1192,6 +1192,45 @@ impl Decimal {
/// ```
#[must_use]
pub fn round_sf(&self, digits: u32) -> Option<Decimal> {
+ self.round_sf_with_strategy(digits, RoundingStrategy::MidpointNe... | 1 | 41 | 4 |
5d1a06fd97d9b4f2fe348381e068969c58cee534 | Paul Mason | 2021-08-28T02:55:01 | Fixes stack overflow on large radian values | diff --git a/src/maths.rs b/src/maths.rs
index 1c76174..273bc74 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -533,6 +533,11 @@ impl MathematicalOps for Decimal {
None => None,
};
}
+ if self >= &Decimal::TWO_PI {
+ // Reduce large numbers early - we can do thi... | 2 | 30 | 0 |
c0ef903865224305f3b17fa6f0a4255caab0a388 | Paul Mason | 2021-08-28T02:26:15 | Clippy suggestion migrating if -> match+cmp | diff --git a/src/decimal.rs b/src/decimal.rs
index 5e5c5b6..80517d1 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1214,62 +1214,67 @@ impl Decimal {
let scale = self.scale();
let current_sf = if scale > mantissa_sf { scale } else { mantissa_sf };
- // If we're requesting a higher numbe... | 1 | 57 | 52 |
05db2ec7fb9cbf9a1e2aee54e1430f0f0d496ace | Paul Mason | 2021-08-28T02:02:52 | Initial implementation for significant figure rounding | diff --git a/src/decimal.rs b/src/decimal.rs
index 1d68296..5e5c5b6 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1157,6 +1157,122 @@ impl Decimal {
self.round_dp_with_strategy(dp, RoundingStrategy::MidpointNearestEven)
}
+ /// Returns `Some(Decimal)` number rounded to the specified number of ... | 2 | 165 | 0 |
d50a0b281222173c3b781af84cc91e34d8b36fac | Caio | 2021-08-27T21:03:45 | Add more fuzz tests | diff --git a/fuzz/fuzz_targets/arithmetic.rs b/fuzz/fuzz_targets/arithmetic.rs
index 647b38b..60a3450 100644
--- a/fuzz/fuzz_targets/arithmetic.rs
+++ b/fuzz/fuzz_targets/arithmetic.rs
@@ -13,6 +13,7 @@ struct Data {
libfuzzer_sys::fuzz_target!(|data: Data| {
let _ = data.a.checked_add(data.b);
+ let _ = dat... | 1 | 3 | 0 |
6458292051a366aa8c8830e645be69d1dd8db1c1 | Paul Mason | 2021-08-27T01:09:16 | Address new clippy warnings from unnecessary borrows | diff --git a/src/decimal.rs b/src/decimal.rs
index e4c18f8..1d68296 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -1948,7 +1948,7 @@ impl<'a, 'b> Add<&'b Decimal> for &'a Decimal {
#[inline(always)]
fn add(self, other: &Decimal) -> Decimal {
- match ops::add_impl(&self, other) {
+ match ... | 4 | 10 | 10 |
472b2b10266db89c06d4d2f92ab793d10d4906df | Paul Mason | 2021-08-27T01:00:36 | Added tan(x) functionality | diff --git a/src/maths.rs b/src/maths.rs
index 8d87228..1c76174 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -7,6 +7,8 @@ const EXP_TOLERANCE: Decimal = Decimal::from_parts(2, 0, 0, false, 7);
const LN10_INVERSE: Decimal = Decimal::from_parts_raw(1763037029, 1670682625, 235431510, 1835008);
// Total iterations of ... | 2 | 141 | 0 |
e6e0e5906c33d227aebe5a9a00f4bea6f5060d2e | Caio | 2021-08-22T21:40:53 | Remove unecessary arrayvec feature
`rust-decimal` does not use any features provided by the `std` flag of `arrayvec`, therefore, unnecessary . | diff --git a/Cargo.toml b/Cargo.toml
index 0590e8f..b762d93 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -56,7 +56,7 @@ serde-arbitrary-precision = ["serde", "serde_json/arbitrary_precision"]
serde-bincode = ["serde-str"] # Backwards compatability
serde-float = ["serde"]
serde-str = ["serde"]
-std = ["arrayvec/std"]
... | 1 | 1 | 1 |
cce6f732593da81d979fa15025b4435c82e9044d | Caio | 2021-08-20T23:21:20 | Add benchmarks to compare different structures | diff --git a/Cargo.toml b/Cargo.toml
index c336d2b..0590e8f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,16 +1,21 @@
+[[bench]]
+harness = false
+name = "comparison"
+path = "benches/comparison.rs"
+
[package]
authors = ["Paul Mason <paul@form1.co.nz>"]
categories = ["science","data-structures"]
description = "A ... | 2 | 58 | 2 |
0a36072048c006ec3bc4eaaf7db650418b155e77 | Paul Mason | 2021-08-20T01:48:31 | Revert "Merge pull request #415 from c410-f3r/benc"
This reverts commit b3e5eeb328d3643212d3784c8596bf85c0ae2871, reversing
changes made to 3c0f76b6a63b89a7c345630150f0f01286bd65a0. | diff --git a/Cargo.toml b/Cargo.toml
index d1cf6d7..c336d2b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,21 +1,16 @@
-[[bench]]
-harness = false
-name = "libraries"
-path = "benches/libraries.rs"
-
[package]
authors = ["Paul Mason <paul@form1.co.nz>"]
categories = ["science","data-structures"]
description = "A De... | 2 | 2 | 68 |
c7c8e027adaf33eb71cb70a5d3b9de0092ff62f1 | Caio | 2021-08-14T19:18:37 | Add benchmarks to compare different structures | diff --git a/Cargo.toml b/Cargo.toml
index c336d2b..d1cf6d7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,16 +1,21 @@
+[[bench]]
+harness = false
+name = "libraries"
+path = "benches/libraries.rs"
+
[package]
authors = ["Paul Mason <paul@form1.co.nz>"]
categories = ["science","data-structures"]
description = "A De... | 2 | 68 | 2 |
c2b3fd19655d102edb519884e94cdcd125a61c9d | Paul Mason | 2021-08-11T03:11:25 | Added approximate precision matching | diff --git a/src/maths.rs b/src/maths.rs
index cea8491..8d87228 100644
--- a/src/maths.rs
+++ b/src/maths.rs
@@ -6,7 +6,7 @@ const EXP_TOLERANCE: Decimal = Decimal::from_parts(2, 0, 0, false, 7);
// Approximation of 1/ln(10) = 0.4342944819032518276511289189
const LN10_INVERSE: Decimal = Decimal::from_parts_raw(176303... | 3 | 64 | 27 |
02a84a1ec4d00e90fc8296d0ee8ce7c026a4d006 | Paul Mason | 2021-08-11T02:20:35 | Add cosine tests | diff --git a/tests/decimal_tests.rs b/tests/decimal_tests.rs
index 26679c6..d6413f4 100644
--- a/tests/decimal_tests.rs
+++ b/tests/decimal_tests.rs
@@ -3744,6 +3744,20 @@ mod maths {
("4.7123889803846898576939650749", Some("0")),
// Cos(2PI)
("6.2831853071795864769252867666", Som... | 1 | 14 | 0 |
8d064d309f0b280d48fe57611927b07df950eb2a | Paul Mason | 2021-08-11T02:16:48 | Added some more sin tests | diff --git a/tests/decimal_tests.rs b/tests/decimal_tests.rs
index 3043b01..26679c6 100644
--- a/tests/decimal_tests.rs
+++ b/tests/decimal_tests.rs
@@ -3709,6 +3709,14 @@ mod maths {
("4.7123889803846898576939650749", Some("-1")),
// Sin(2PI)
("6.2831853071795864769252867666", So... | 1 | 8 | 0 |
bf5a79288eb69bc0d3a2cf452730c65aae349348 | Paul Mason | 2021-08-11T01:45:34 | Initial implementation of sin/cos functions using taylor series | diff --git a/src/decimal.rs b/src/decimal.rs
index 2dc960d..e4c18f8 100644
--- a/src/decimal.rs
+++ b/src/decimal.rs
@@ -192,6 +192,14 @@ impl Decimal {
mid: 92937282,
hi: 851530395,
};
+ /// A constant representing π/4 as 0.7853981633974483096156608458
+ #[cfg(feature = "maths")]
+ pub ... | 3 | 169 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.