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 |
|---|---|---|---|---|---|---|---|
6e457b31e2e42a4c7b22b11bf9a5e971b55afbbe | Andrew Kubera | 2024-06-09T02:30:57 | Use the scale safety-limit when parsing json | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 989f982..1b25fd5 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -293,10 +293,14 @@ pub mod arbitrary_precision {
where
D: serde::de::Deserializer<'de>,
{
- serde_json::Number::deserialize(deserializer)?
- ... | 1 | 21 | 4 |
03d7241821c3ad9b68a7e119cfb0046d97503201 | Andrew Kubera | 2024-06-08T03:31:14 | Add compile-time variable safely limit when parsing json | diff --git a/build.rs b/build.rs
index 8321164..414eba9 100644
--- a/build.rs
+++ b/build.rs
@@ -8,6 +8,8 @@ const FMT_EXPONENTIAL_LOWER_THRESHOLD: &str = "5";
const FMT_EXPONENTIAL_UPPER_THRESHOLD: &str = "15";
const FMT_MAX_INTEGER_PADDING: &str = "1000";
+const SERDE_MAX_SCALE: &str = "150000";
+
fn main() {
... | 2 | 24 | 0 |
fb2db646f0505b90c6ca5acdc05e53432fb9d6f3 | Andrew Kubera | 2024-06-05T05:21:36 | Add test for json number serialization | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index a23b762..a7a2e61 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -226,6 +226,38 @@ mod test {
assert_de_tokens_error::<BigDecimal>(&tokens, "NAN");
}
}
+
+
+ #[cfg(feature = "serde_json")]
+ mod json_support {
+ u... | 2 | 35 | 0 |
654bed16a73b59ddc0394e729f0531ec30363074 | Andrew Kubera | 2024-06-02T18:01:47 | Update formatting in serde test | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 089e7b9..a23b762 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -136,7 +136,7 @@ mod test {
impl_case!(case_50: "50" => "50");
impl_case!(case_50000: "50000" => "50000");
impl_case!(case_1en3: "1e-3" => "0.001");
- imp... | 1 | 1 | 1 |
09d634b107f3beb1315dad23287a62ded114406f | Andrew Kubera | 2024-06-02T18:01:24 | Add more methods to BigDecimalVisitor impl | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 7d872bb..089e7b9 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -45,12 +45,47 @@ impl<'de> de::Visitor<'de> for BigDecimalVisitor {
Ok(BigDecimal::from(value))
}
+ fn visit_u128<E>(self, value: u128) -> Result<BigDecimal, E>
+ whe... | 1 | 35 | 0 |
4c9739dc1b174cc97e1009784836c5f510f2e09f | Andrew Kubera | 2024-03-06T19:10:43 | Modify formatting in impl_serde | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index f912e83..7d872bb 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -224,8 +224,10 @@ pub mod arbitrary_precision {
where
D: serde::de::Deserializer<'de>,
{
- serde_json::Number::deserialize(deserializer)?.to_string().parse().map_... | 1 | 14 | 9 |
27192f56a740464cbd8a9a3efa3ebb53ed9a3b31 | Andrew Kubera | 2024-03-06T18:33:23 | Export serde_json derive-modules via bigdecimal::serde | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 4437908..f912e83 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -2,7 +2,7 @@
//! Support for serde implementations
//!
use crate::*;
-use serde::{de, ser};
+use serde_crate::{self as serde, de, ser, Serialize, Deserialize};
impl ser::Serialize ... | 2 | 72 | 51 |
467ec3e468a1573ccb89f84745ae578ce01115c8 | Andrew Kubera | 2024-03-06T17:56:29 | Replace arbitrary-precision with serde_json | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 45e4c86..4437908 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -206,7 +206,7 @@ mod test {
///
/// #[derive(Serialize, Deserialize)]
/// pub struct ArbitraryExample {
-/// #[serde(with = "bigdecimal::impl_serde::arbitrary_precision")]
+/// ... | 2 | 11 | 7 |
48e1aac64d908dd015de24b7922d8b53ae5d6b42 | Andrew Kubera | 2024-03-06T17:21:56 | Simplify serde dependency requirements | diff --git a/Cargo.toml b/Cargo.toml
index acbe295..9d98248 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,10 +25,8 @@ num-bigint = { version = "<0.4.5", default-features = false }
num-integer = { version = "0.1", default-features = false }
num-traits = { version = "<0.2.19", default-features = false }
serde = { ve... | 1 | 3 | 5 |
2abd7bb83458f13f98400e936cb051493d194d76 | tenuous-guidance | 2023-11-03T20:21:05 | Support running the tests on an old version of rust | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 2adb5f8..45e4c86 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -196,7 +196,9 @@ mod test {
/// Serialize/deserialize [`BigDecimal`] as arbitrary precision numbers in JSON using the `arbitrary_precision` feature within `serde_json`.
///
-/// ```
+/... | 1 | 13 | 22 |
21033d20d67aee408db96af4fa24ff9bc378b4c9 | tenuous-guidance | 2023-11-03T19:12:57 | Add support for serde_json's arbitrary precision | diff --git a/Cargo.toml b/Cargo.toml
index a8ff71e..acbe295 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,6 +25,10 @@ num-bigint = { version = "<0.4.5", default-features = false }
num-integer = { version = "0.1", default-features = false }
num-traits = { version = "<0.2.19", default-features = false }
serde = { ve... | 2 | 173 | 0 |
d2779525ca0f0a1ad7cf239cc5e153d15af30c76 | Andrew Kubera | 2024-06-01T18:31:54 | Restrict versions of num-* dependencies | diff --git a/Cargo.toml b/Cargo.toml
index 543d4a7..a8ff71e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,9 +21,9 @@ bench = false
[dependencies]
libm = "0.2.6"
-num-bigint = { version = "0.4", default-features = false }
+num-bigint = { version = "<0.4.5", default-features = false }
num-integer = { version = "0.... | 1 | 2 | 2 |
8a423f24d4e32b7e1e7c071abf21edae8d78ecad | Andrew Kubera | 2024-06-01T17:50:13 | Add test-case for engineering_notation producing out-of-bounds exponent | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index f81f2ee..9668896 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -933,6 +933,26 @@ mod test {
assert_eq!(eng_round_trip, bd);
}
};
+ ( (eng-check-invalid) $name:ident: $src:expr => $expected:literal ... | 1 | 21 | 1 |
69a1ab33b4cc21b8607e02e4090ffb37456bd3d7 | Andrew Kubera | 2024-05-27T22:43:28 | Add test cases | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 3ea5494..f81f2ee 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -797,9 +797,9 @@ mod test {
"1e16".parse().unwrap()
}
- impl_case!(fmt_default: "{}" => "1e16");
+ impl_case!(fmt_default: "{}" ... | 1 | 36 | 19 |
9d58d8aebdb9ea0ec16773ced20a0e90cff31baf | Andrew Kubera | 2024-05-27T21:33:23 | Add function format_dotless_exponential | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 688f7ec..3ea5494 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -94,13 +94,20 @@ fn dynamically_format_decimal(
// number of zeros between least significant digit and decimal point
let trailing_zero_count = this.scale
... | 1 | 27 | 3 |
0bfe54d705c32132b6d507befee1e5a3da9e11e5 | Andrew Kubera | 2024-05-14T04:43:13 | Add more formatting tests | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 9e91536..688f7ec 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -571,7 +571,7 @@ mod test {
impl_case!(case_0d000123: "0.000123" => "1.23E-4");
impl_case!(case_123d: "123." => "123");
- impl_case!(case_123de1: "123.e1" => "1.23E+3");... | 1 | 31 | 4 |
cca95ec93ea1b1c62cac14556587c297df04ffd7 | Andrew Kubera | 2024-05-14T02:51:56 | Change the context variables | diff --git a/build.rs b/build.rs
index 30b6301..8321164 100644
--- a/build.rs
+++ b/build.rs
@@ -4,8 +4,9 @@ use std::path::{Path, PathBuf};
// configuration defaults
const DEFAULT_PRECISION: &str = "100";
const DEFAULT_ROUNDING_MODE: &str = "HalfEven";
-const EXPONENTIAL_FORMAT_THRESHOLD: &str = "5";
-const EXPONEN... | 2 | 18 | 10 |
f3969e3c24611d6417dc923f67ed7dc06497fdee | Andrew Kubera | 2024-05-12T23:54:05 | Add test dec_n90037659d6902 | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index fe7f68b..c1cefb6 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -715,6 +715,25 @@ mod test {
impl_case!(fmt_010d3: "{:010.3}" => "019073.972");
}
+ mod dec_n90037659d6902 {
+ use super::*;
+
+ fn test_input... | 1 | 19 | 0 |
79f513e77f296eefccb277fcd6c9e1326de5da1b | Andrew Kubera | 2024-05-12T20:07:54 | Refactor format_full_scale into smaller implementation functions | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 4b856b6..fe7f68b 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -5,8 +5,8 @@ use crate::*;
use stdlib::fmt::Write;
-// const EXPONENTIAL_FORMAT_THRESHOLD: i64 = ${RUST_BIGDECIMAL_EXPONENTIAL_FORMAT_THRESHOLD} or 5;
-// const EXPONENTIAL_FORMAT_UPPER_THRES... | 1 | 122 | 71 |
6386ff6a20799c1d477ff937f60a9e1cf63538ec | Andrew Kubera | 2024-05-12T19:56:29 | Reimplement tests for BigDecimal::normalized | diff --git a/src/lib.rs b/src/lib.rs
index a1b1a30..f692b90 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1968,33 +1968,29 @@ mod bigdecimal_tests {
assert!((-BigDecimal::one()).abs().is_positive());
}
- #[test]
- fn test_normalize() {
- use num_bigint::BigInt;
-
- let vals = vec![
- ... | 1 | 21 | 25 |
5465b3892520d7cc0400ce9525d553bf52b7f9e3 | Andrew Kubera | 2024-04-23T00:28:26 | Double fmt threshold | diff --git a/build.rs b/build.rs
index 6485030..6f4fd88 100644
--- a/build.rs
+++ b/build.rs
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
const DEFAULT_PRECISION: &str = "100";
const DEFAULT_ROUNDING_MODE: &str = "HalfEven";
const EXPONENTIAL_FORMAT_THRESHOLD: &str = "5";
-const EXPONENTIAL_FORMAT_UPPER_THRESHOLD... | 2 | 37 | 11 |
5b653af0fb4c1a52d2fc5d346b217d82870a1599 | Andrew Kubera | 2024-04-22T00:25:05 | Add EXPONENTIAL_FORMAT_UPPER_THRESHOLD variable in build.rs | diff --git a/build.rs b/build.rs
index e6281cc..6485030 100644
--- a/build.rs
+++ b/build.rs
@@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};
const DEFAULT_PRECISION: &str = "100";
const DEFAULT_ROUNDING_MODE: &str = "HalfEven";
const EXPONENTIAL_FORMAT_THRESHOLD: &str = "5";
+const EXPONENTIAL_FORMAT_UPPER_THRESHOLD... | 2 | 16 | 6 |
d1419bc7a179046000966ade71d3a4f7a582ea9a | Andrew Kubera | 2024-04-21T18:21:18 | Clean build.rs environment variable loading | diff --git a/build.rs b/build.rs
index 0db0ca3..e6281cc 100644
--- a/build.rs
+++ b/build.rs
@@ -1,7 +1,11 @@
-
use std::env;
use std::path::{Path, PathBuf};
+// configuration defaults
+const DEFAULT_PRECISION: &str = "100";
+const DEFAULT_ROUNDING_MODE: &str = "HalfEven";
+const EXPONENTIAL_FORMAT_THRESHOLD: &str ... | 1 | 15 | 8 |
5c91f49348fccc40400087d08c4e4594d1683f5c | Andrew Kubera | 2024-04-18T00:09:59 | Add example script printing various decimal formats | diff --git a/examples/formatting-examples.rs b/examples/formatting-examples.rs
new file mode 100644
index 0000000..447dc51
--- /dev/null
+++ b/examples/formatting-examples.rs
@@ -0,0 +1,66 @@
+
+extern crate bigdecimal;
+extern crate num_traits;
+
+use bigdecimal::BigDecimal;
+
+
+macro_rules! print_varying_values {
+ ... | 1 | 66 | 0 |
a6106a921f8263f8b5ddf2151556d60224b16ea5 | Andrew Kubera | 2024-04-14T18:51:09 | Replace formatting tests | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index a56c4ef..bbbff41 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -433,6 +433,7 @@ fn apply_rounding_to_ascii_digits(
#[cfg(test)]
+#[allow(non_snake_case)]
mod test {
use super::*;
use paste::*;
@@ -516,12 +517,68 @@ mod test {
}
... | 1 | 192 | 50 |
2bb507335e08c66932adb4d15f57c8331f34b929 | Nikola Ilo | 2018-05-24T01:20:52 | Restore expected results for test_fmt
Reverts test contents to those originally added in commit cdb05cfb42998b07b | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 9acd68e..a56c4ef 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -629,14 +629,14 @@ mod test {
#[test]
fn test_fmt() {
let vals = vec![
- // b s ( {} {:.1} {:.4} {:4.1} {:+05.7} {:<6.4}
- (1, 0, ( ... | 1 | 10 | 10 |
ded7f6c7e150589f18d7b70b1e1641892805cbb3 | Andrew Kubera | 2024-04-14T18:43:32 | Reimplement formatting routines | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index e5dc677..9acd68e 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -96,60 +96,81 @@ fn format_full_scale(
debug_assert_ne!(digits.len(), 0);
- match f.precision() {
- // precision limits the number of digits - we have to round
- Some(pre... | 1 | 111 | 56 |
8344feccac8c83da863a06a9d7cb25cd932c9bd3 | Andrew Kubera | 2024-03-30T21:24:10 | Fix clippy suggestions | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index d4710f9..e5dc677 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -230,7 +230,7 @@ fn format_exponential(
//
// For the (abs_int.len() - this.scale) == abs_int.len() I couldn't
// come up with an example
- let exponent = abs_int.len() a... | 2 | 2 | 3 |
e0cf671b78972660d1a3b15a44362395904908cc | Andrew Kubera | 2024-03-29T23:45:23 | Add highest-bit optimization to compare functions | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index 4e6c43e..69be708 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -66,15 +66,9 @@ fn check_equality_bigdecimal_ref(lhs: BigDecimalRef, rhs: BigDecimalRef) -> bool
debug_assert_ne!(trailing_zero_count, 0);
- // multiplying by 10^trailing_zero_count gu... | 1 | 29 | 9 |
335f9815dfc5038a71fc4c4313c436da96ac7850 | Andrew Kubera | 2024-03-29T22:21:40 | Optimize and add new tests to equality check | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index 9f2ab5e..4e6c43e 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -64,6 +64,20 @@ fn check_equality_bigdecimal_ref(lhs: BigDecimalRef, rhs: BigDecimalRef) -> bool
}
}
+ debug_assert_ne!(trailing_zero_count, 0);
+
+ // multiplying by 10^trai... | 1 | 37 | 7 |
3683c9662c69082cb23591f67bc1b4ff63b978f9 | Andrew Kubera | 2024-03-29T20:17:43 | Replace unwrap in count_decimal_digits_uint | diff --git a/src/arithmetic/mod.rs b/src/arithmetic/mod.rs
index afc29b8..c6df8fc 100644
--- a/src/arithmetic/mod.rs
+++ b/src/arithmetic/mod.rs
@@ -75,7 +75,7 @@ pub(crate) fn count_decimal_digits_uint(uint: &BigUint) -> u64 {
}
let mut digits = (uint.bits() as f64 / LOG2_10) as u64;
// guess number of ... | 1 | 1 | 1 |
f4b09ff2d1b574dbe56e20077faf6d459715e2cb | Andrew Kubera | 2024-03-29T19:46:30 | Test new implementations of PartialEq and Ord | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index 8d5b484..9f2ab5e 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -299,43 +299,88 @@ where
#[cfg(test)]
-mod tests {
+mod test {
use super::*;
- macro_rules! impl_test {
- ($name:ident: $a:literal > $b:literal e $e:literal) => {
- ... | 1 | 76 | 31 |
168734428a67be53de5a2fb0c99c6fc809fb063b | Andrew Kubera | 2024-03-29T18:18:15 | Reimplement equality with safer and faster algorithm | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index 0f18a99..8d5b484 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -26,52 +26,103 @@ where
{
fn eq(&self, rhs: &T) -> bool {
let rhs: BigDecimalRef<'rhs> = (*rhs).into();
+ check_equality_bigdecimal_ref(*self, rhs)
+ }
+}
- match... | 1 | 87 | 36 |
d30fe8d58ca9ad4374ac80380caac963e478a5df | Andrew Kubera | 2024-03-29T17:02:54 | Use checked_diff in Ord implementation | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index e678b29..0f18a99 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -129,13 +129,21 @@ impl Ord for BigDecimalRef<'_> {
return Ordering::Equal;
}
- let result = match arithmetic::diff(self.scale, other.scale) {
- (Greater,... | 1 | 11 | 3 |
901f9e455b10d682e6dd447842797ccfd0960c13 | Andrew Kubera | 2024-03-29T17:02:09 | Add function arithmetic::checked_diff | diff --git a/src/arithmetic/mod.rs b/src/arithmetic/mod.rs
index 46644bc..afc29b8 100644
--- a/src/arithmetic/mod.rs
+++ b/src/arithmetic/mod.rs
@@ -1,6 +1,7 @@
//! arithmetic routines
use crate::*;
+use num_traits::CheckedSub;
pub(crate) mod addition;
pub(crate) mod sqrt;
@@ -86,14 +87,28 @@ pub(crate) fn coun... | 1 | 19 | 4 |
0923b7ed4ef0bb188a8d753d1ccc9f1cef6afeea | Andrew Kubera | 2024-03-29T05:55:39 | Test compare_scaled_biguints | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index 46d4409..e678b29 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -240,9 +240,44 @@ where
#[cfg(test)]
-mod test_bigintref {
+mod tests {
use super::*;
- use stdlib::ops::Neg;
+
+ macro_rules! impl_test {
+ ($name:ident: $a:literal > $b:li... | 1 | 61 | 2 |
4da1c97bf168480a644a9df11d433c259a1614cc | Andrew Kubera | 2024-03-29T05:41:49 | Reimplement Ord, avoiding allocations | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index c2893fc..46d4409 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -8,11 +8,7 @@
//! &BigDecimal and BigDecimalRef are comparable.
//!
-use crate::{
- BigDecimal,
- BigDecimalRef,
- Sign,
-};
+use crate::*;
use stdlib::cmp::Ordering;
use stdlib::... | 1 | 110 | 14 |
7bfaac36e4d79d6ba2086cae63d6ffa67bb01d85 | Andrew Kubera | 2024-03-29T03:24:40 | Implement Ord and PartialOrd for BigDecimalRef | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index de961f9..c2893fc 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -86,7 +86,21 @@ impl PartialOrd for BigDecimal {
}
}
+impl PartialOrd for BigDecimalRef<'_> {
+ fn partial_cmp(&self, other: &BigDecimalRef<'_>) -> Option<Ordering> {
+ Some(self... | 2 | 17 | 3 |
255e7343b82a07a0ea6d1bf539bbfce5de357bef | Andrew Kubera | 2024-03-29T03:09:29 | Move Ord & PartialOrd impls to impl_cmp.rs | diff --git a/src/impl_cmp.rs b/src/impl_cmp.rs
index 32f7019..de961f9 100644
--- a/src/impl_cmp.rs
+++ b/src/impl_cmp.rs
@@ -79,6 +79,56 @@ where
}
+impl PartialOrd for BigDecimal {
+ #[inline]
+ fn partial_cmp(&self, other: &BigDecimal) -> Option<Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl ... | 2 | 50 | 48 |
00c9e7bd32c466b465e858ec915fbd8921a795bf | Andrew Kubera | 2024-03-25T01:39:53 | Add method BigDecimal::set_scale | diff --git a/src/lib.rs b/src/lib.rs
index 4ed93da..684159a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -383,9 +383,15 @@ impl BigDecimal {
/// Useful for aligning decimals before adding/subtracting.
///
fn take_and_scale(mut self, new_scale: i64) -> BigDecimal {
+ self.set_scale(new_scale);
+ ... | 1 | 7 | 3 |
d6d6deb2c555e70682f2ebcc21f1f60fd11fee16 | Andrew Kubera | 2023-10-22T23:42:50 | Add method BigDecimalRef::clone_into | diff --git a/src/lib.rs b/src/lib.rs
index c8b328c..4ed93da 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1331,6 +1331,12 @@ impl BigDecimalRef<'_> {
pub fn is_zero(&self) -> bool {
self.digits.is_zero()
}
+
+ /// Clone this value into dest
+ pub fn clone_into(&self, dest: &mut BigDecimal) {
+ ... | 1 | 6 | 0 |
ee5e9f229a5d57691f3005fe980faa2ebe252755 | Andrew Kubera | 2024-03-05T08:16:28 | Begin v0.4.4 development | diff --git a/Cargo.toml b/Cargo.toml
index b388e00..543d4a7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.4.3"
+version = "0.4.4+dev"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
ea6eb2feecbb8b607221d795fc23e4a9d361e9bc | Andrew Kubera | 2024-03-05T06:59:36 | Version 0.4.3 | diff --git a/Cargo.toml b/Cargo.toml
index 50c9dfd..b388e00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.4.3+dev"
+version = "0.4.3"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
03105f31ee97eaedfb1eea3155a1f258b6195e28 | Andrew Kubera | 2024-03-05T06:52:30 | Preserve scale when adding zero and add minor optimize add_bigdecimals | diff --git a/src/arithmetic/addition.rs b/src/arithmetic/addition.rs
index 00d1881..11f04b9 100644
--- a/src/arithmetic/addition.rs
+++ b/src/arithmetic/addition.rs
@@ -9,22 +9,45 @@ pub(crate) fn add_bigdecimals(
mut b: BigDecimal,
) -> BigDecimal {
if b.is_zero() {
+ if a.scale < b.scale {
+ ... | 1 | 30 | 7 |
83f537d3a10b9b9a377e67246f60f4e5e14586e4 | Andrew Kubera | 2024-03-05T06:21:31 | Reimplement take_and_scale with diff and ten_to_the_u64 | diff --git a/src/lib.rs b/src/lib.rs
index 42a0a0f..c8b328c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -141,6 +141,7 @@ pub use context::Context;
use arithmetic::{
ten_to_the,
ten_to_the_uint,
+ ten_to_the_u64,
diff,
diff_usize,
count_decimal_digits,
@@ -383,20 +384,31 @@ impl BigDecimal {... | 1 | 21 | 9 |
a0c7df42eb44df8ed47ed1efba2da33410a17192 | Andrew Kubera | 2024-03-05T06:19:01 | Add ten_to_the_u64 | diff --git a/src/arithmetic/mod.rs b/src/arithmetic/mod.rs
index 9580441..46644bc 100644
--- a/src/arithmetic/mod.rs
+++ b/src/arithmetic/mod.rs
@@ -15,6 +15,12 @@ pub(crate) fn ten_to_the(pow: u64) -> BigInt {
ten_to_the_uint(pow).into()
}
+/// Return 10^{pow} as u64
+pub(crate) fn ten_to_the_u64(pow: u8) -> u... | 1 | 6 | 0 |
061995477538cf2fb87682111c7256a09ebdefa8 | Andrew Kubera | 2024-03-05T05:01:39 | Move addition implementations to arithmetic module | diff --git a/src/arithmetic/addition.rs b/src/arithmetic/addition.rs
new file mode 100644
index 0000000..00d1881
--- /dev/null
+++ b/src/arithmetic/addition.rs
@@ -0,0 +1,87 @@
+//! addition routines
+//!
+
+use crate::*;
+
+
+pub(crate) fn add_bigdecimals(
+ mut a: BigDecimal,
+ mut b: BigDecimal,
+) -> BigDecim... | 3 | 97 | 62 |
2c66e3635a41635544c146bc193c2b748f17ce45 | Andrew Kubera | 2023-09-26T04:15:59 | Add diff & diff_usize functions to arithmetic module | diff --git a/src/arithmetic/mod.rs b/src/arithmetic/mod.rs
index 614503d..2f6bbf8 100644
--- a/src/arithmetic/mod.rs
+++ b/src/arithmetic/mod.rs
@@ -74,3 +74,30 @@ pub(crate) fn count_decimal_digits_uint(uint: &BigUint) -> u64 {
}
digits
}
+
+
+/// Return difference of two numbers, returning diff as u64
+pub... | 2 | 30 | 0 |
f104e981f58639e2be4db46b62fbba651ce80109 | Amejonah1200 | 2024-03-05T00:29:38 | Add Clone to ParseBigDecimalError | diff --git a/src/lib.rs b/src/lib.rs
index 58b17c1..8dd52e6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -929,7 +929,7 @@ impl BigDecimal {
}
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Clone)]
pub enum ParseBigDecimalError {
ParseDecimal(ParseFloatError),
ParseInt(ParseIntError), | 1 | 1 | 1 |
6d6349dcc7c1c682cd908778631897bcc7710d00 | Andrew Kubera | 2024-02-22T07:51:18 | Add tests for parsing at the boundary | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index f727d33..d4710f9 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -532,6 +532,45 @@ mod test {
}
}
+ mod fmt_boundaries {
+ use super::*;
+
+ macro_rules! impl_case {
+ ( $name:ident: $src:expr => $expected:literal ) =... | 1 | 39 | 0 |
24d9b5873174461ad8086c56497adde95b73a40f | Andrew Kubera | 2024-02-22T07:50:19 | Change more i64 casts to i128 in impl_fmt | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index c9b1525..f727d33 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -91,7 +91,7 @@ fn format_full_scale(
use stdlib::cmp::Ordering::*;
let mut digits = abs_int.into_bytes();
- let mut exp = -this.scale;
+ let mut exp = (this.scale as i128).neg();... | 1 | 11 | 6 |
65a12d9ae8e0e9825e61061d71281828e1dbe8df | Andrew Kubera | 2024-02-22T06:45:27 | Avoid unnecessary copies in from_str_radix | diff --git a/src/impl_num.rs b/src/impl_num.rs
index 0afe9d5..32d1e5d 100644
--- a/src/impl_num.rs
+++ b/src/impl_num.rs
@@ -54,26 +54,33 @@ impl Num for BigDecimal {
return Err(ParseBigDecimalError::Empty);
}
+ let mut digit_buffer = String::new();
+
+ let last_digit_loc = base_pa... | 1 | 15 | 8 |
f90d436f826f112e666bbe95170b5a434f794fdf | Andrew Kubera | 2024-02-22T06:25:11 | Fix overflows and false negatives in from_str_radix | diff --git a/src/impl_num.rs b/src/impl_num.rs
index 8136973..0afe9d5 100644
--- a/src/impl_num.rs
+++ b/src/impl_num.rs
@@ -44,16 +44,8 @@ impl Num for BigDecimal {
// split and parse exponent field
Some(loc) => {
// slice up to `loc` and 1 after to skip the 'e' char
- ... | 1 | 14 | 19 |
908a03eca4c6bae7bdbb79834a5a8b461e9a4402 | Andrew Kubera | 2024-02-22T05:29:54 | Avoid overflow error in to_string exponential calculation | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 2d299e1..c9b1525 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -230,7 +230,7 @@ fn format_exponential(
//
// For the (abs_int.len() - this.scale) == abs_int.len() I couldn't
// come up with an example
- let exponent = abs_int.len() a... | 1 | 1 | 1 |
f5746390c196803d4c7b4ed17f86b3a729dd3044 | Andrew Kubera | 2024-02-12T23:45:29 | Move rounding tests into separate file | diff --git a/src/rounding.rs b/src/rounding.rs
index bbce7f1..0a39655 100644
--- a/src/rounding.rs
+++ b/src/rounding.rs
@@ -199,273 +199,4 @@ impl RoundingMode {
#[cfg(test)]
-#[allow(non_snake_case)]
-mod test_round_pair {
- use paste::paste;
- use super::*;
-
- macro_rules! impl_test {
- ( $($mo... | 2 | 272 | 270 |
f35ed99a4a4aa2e2062a0b39296e622371d1d582 | Andrew Kubera | 2024-01-21T18:14:23 | Add roundtrip tests for {scientific,engineering}-notation methods | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index d2c50e0..2d299e1 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -689,7 +689,7 @@ mod test {
mod proptests {
use super::*;
use paste::paste;
- use proptest::*;
+ use proptest::prelude::*;
macro_rules! impl_parsing_test {
($t:ty)... | 1 | 23 | 1 |
379e1c20e77f8702414dfc05ab6bcc927371b283 | Andrew Kubera | 2024-01-21T01:32:16 | Fix serde test | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index e8bdac7..6ba601d 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -101,7 +101,7 @@ mod test {
impl_case!(case_50: "50" => "50");
impl_case!(case_50000: "50000" => "50000");
impl_case!(case_1en3: "1e-3" => "0.001");
- imp... | 1 | 1 | 1 |
b0efb6350e2f684fed21592c4b08cc28fa0896fc | Andrew Kubera | 2024-01-21T00:55:00 | Update formatting tests to new standards | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 2465e56..b65b0de 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -431,20 +431,113 @@ mod test {
impl_case!(case_0d000123: "0.000123" => "1.23E-4");
impl_case!(case_123d: "123." => "123");
- impl_case!(case_123de1: "123.e1" => "1.23E3"... | 1 | 114 | 35 |
2a0b0ec00e937d7f0d0b77ee0a88594308773044 | Andrew Kubera | 2024-01-20T22:51:52 | Update fmt_debug for new behavior | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index c8256c5..2465e56 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -53,7 +53,7 @@ impl fmt::UpperExp for BigDecimalRef<'_> {
impl fmt::Debug for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if f.alternate() {
- wri... | 1 | 103 | 55 |
13ee734f32976a1254752936c69770788fc9683a | Andrew Kubera | 2024-01-20T22:05:11 | Update test_normalize for new fmt implementation | diff --git a/src/lib.rs b/src/lib.rs
index def1742..58b17c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2001,10 +2001,10 @@ mod bigdecimal_tests {
"0.1"),
(BigDecimal::new(BigInt::from(132400), -4),
BigDecimal::new(BigInt::from(1324), -6),
- "1324000000"),
+ ... | 1 | 2 | 2 |
467ec4f78b90acad761ca9a6233c87fa932274b3 | Andrew Kubera | 2024-01-20T21:27:51 | Implement fmt::{Upper,Lower}Exp traits and improve Debug | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index aad97f0..c8256c5 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -11,7 +11,7 @@ include!(concat!(env!("OUT_DIR"), "/exponential_format_threshold.rs"));
impl fmt::Display for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- dy... | 1 | 38 | 7 |
2c0d3e377cb3a24881ebae3ac82d4120d3a6d8d2 | Andrew Kubera | 2024-01-20T21:08:25 | Change default EXPONENTIAL_THRESHOLD to 5 | diff --git a/build.rs b/build.rs
index 32d61f4..0db0ca3 100644
--- a/build.rs
+++ b/build.rs
@@ -50,7 +50,7 @@ fn write_default_rounding_mode(outdir: &Path) {
/// Create write_default_rounding_mode.rs, containing definition of constant EXPONENTIAL_FORMAT_THRESHOLD loaded in src/impl_fmt.rs
fn write_exponential_form... | 1 | 1 | 1 |
b57f528840323a2e2b94d469266d5d0e34372cc8 | Andrew Kubera | 2024-01-20T21:06:35 | Update format_full_scale to round and avoid allocations | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 06dd068..aad97f0 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -41,6 +41,9 @@ fn dynamically_format_decimal(
// Acquire the absolute integer as a decimal string
let abs_int = this.digits.to_str_radix(10);
+ // use exponential form if decimal po... | 2 | 129 | 43 |
a75e152f6b47ba523f3a857c1b73491ea930121f | Andrew Kubera | 2024-01-18T02:42:30 | Change exp-form threshold calculation | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 3c0047c..06dd068 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -41,7 +41,7 @@ fn dynamically_format_decimal(
// Acquire the absolute integer as a decimal string
let abs_int = this.digits.to_str_radix(10);
- if (abs_int.len() as i64 - this.scale... | 1 | 43 | 1 |
61919f3c703025ab57a671eacec923ace293a033 | Andrew Kubera | 2024-01-17T07:18:08 | Support RUST_BIGDECIMAL_EXPONENTIAL_FORMAT_THRESHOLD in build.rs | diff --git a/build.rs b/build.rs
index 8e43e1a..32d61f4 100644
--- a/build.rs
+++ b/build.rs
@@ -16,6 +16,7 @@ fn main() {
let outdir: PathBuf = std::env::var_os("OUT_DIR").unwrap().into();
write_default_precision_file(&outdir);
write_default_rounding_mode(&outdir);
+ write_exponential_format_threshol... | 2 | 22 | 4 |
57075470f79ce8e90a122a4168327339f1cfa579 | Andrew Kubera | 2024-01-18T06:48:38 | Fix Rust compatibility issue | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 133d4fb..fc5ccc7 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -322,12 +322,12 @@ mod test {
];
for (i, scale, results) in vals {
let x = BigDecimal::new(num_bigint::BigInt::from(i), scale);
- assert_eq!(format!("{}",... | 2 | 7 | 7 |
78d350a512e019885e4191d620177c00769d96c9 | Andrew Kubera | 2024-01-18T01:28:02 | Impl Display for BigDecimalRef | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index aa746c3..133d4fb 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -9,7 +9,15 @@ impl fmt::Display for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const EXPONENTIAL_FORMAT_THRESHOLD: i64 = 25;
- dynamically_format_de... | 1 | 16 | 7 |
93377ecd5ab45c7cf98934cbbccc2f7b544378e7 | Andrew Kubera | 2024-01-18T01:19:31 | Move BigDecimal::Display:fmt implementation into new function | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index b13aac8..aa746c3 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -9,14 +9,7 @@ impl fmt::Display for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const EXPONENTIAL_FORMAT_THRESHOLD: i64 = 25;
- // Acquire the absolu... | 1 | 16 | 8 |
c4dd7fe4ea4d164f36f87adc5f123396eb8b0476 | Declan Kelly | 2024-01-08T23:17:49 | Special case formatting of numbers with large scale
**Description**
Add a second path to the `Display` impl so that numbers that have a
large scale relative to length of their integer representation are
formatted differently. Specifically, I switched it to use
exponential number format like:
```
1.23456789E38
```
ins... | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 34dc398..b13aac8 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -7,57 +7,16 @@ use stdlib::fmt::Write;
impl fmt::Display for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- // Acquire the absolute integer as a decimal strin... | 2 | 163 | 83 |
5ebe932a4ea736b0c52aea31a57a7c9ab60294ce | Declan Kelly | 2024-01-08T20:34:56 | Add more tests for parsing and formatting decimals
**Description**
- Add a test for the format of decimals with a large representation
- Add a test which:
1. Takes a string and parses it to a decimal `N`
2. Converts `N` to a string representation `N_repr
3. Parses `N_repr` as a new decimal `M`
4. Ass... | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 09e2988..34dc398 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -184,6 +184,56 @@ mod test {
}
}
+ #[test]
+ fn test_fmt_with_large_values() {
+ let vals = vec![
+ // b s ( {} {:.1} {:.4} {:4.1} {:+05... | 2 | 147 | 0 |
6aebed75fa2eeaab3f222ec5aabf1ee8a2f1967c | Andrew Kubera | 2023-08-16T05:56:01 | Fix potential panic in write_engineering_notation | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 272c8b5..09e2988 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -115,11 +115,20 @@ pub(crate) fn write_engineering_notation<W: Write>(n: &BigDecimal, out: &mut W)
let shift_amount = match top_digit_exponent.rem_euclid(3) {
0 => 3,
- i =>... | 1 | 18 | 3 |
d9117709072289b73b71895fef88af9b23b1af55 | Andrew Kubera | 2023-08-16T03:27:27 | Move {sci,eng}-notation tests to impl_fmt.rs | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 0cfe860..272c8b5 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -8,7 +8,7 @@ use stdlib::fmt::Write;
impl fmt::Display for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// Acquire the absolute integer as a decimal string
- ... | 3 | 53 | 51 |
3f994f733e8e754293c1887964a5587929d0cbca | Andrew Kubera | 2023-08-16T03:22:46 | Update fmt::Debug tests | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index 677299d..0cfe860 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -64,7 +64,11 @@ impl fmt::Display for BigDecimal {
impl fmt::Debug for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "BigDecimal(\"{}\")", self)
+ ... | 1 | 25 | 13 |
26cff3b16aff1b3092db28ed1f78991f2281ef04 | Andrew Kubera | 2023-07-30T15:27:32 | Add scientific- & engineering- notation functions to impl_fmt.rs | diff --git a/src/impl_fmt.rs b/src/impl_fmt.rs
index cf47821..677299d 100644
--- a/src/impl_fmt.rs
+++ b/src/impl_fmt.rs
@@ -2,6 +2,7 @@
//!
use crate::*;
+use stdlib::fmt::Write;
impl fmt::Display for BigDecimal {
@@ -68,8 +69,68 @@ impl fmt::Debug for BigDecimal {
}
+#[inline(never)]
+pub(crate) fn writ... | 4 | 156 | 1 |
8b614b315eb7d77f59a4b2a0df02604a61fc1109 | Andrew Kubera | 2024-01-17T02:36:16 | Create impl_fmt.rs (history preserving) | diff --git a/src/lib.rs b/src/impl_fmt.rs
similarity index 100%
rename from src/lib.rs
rename to src/impl_fmt.rs | 1 | 0 | 0 |
bceaa0960ae98aeb824864bcdd72d92837ed15a9 | Andrew Kubera | 2024-01-15T22:29:49 | Improve multiplication implementation | diff --git a/src/impl_ops_mul.rs b/src/impl_ops_mul.rs
index 2b1df37..181ce9d 100644
--- a/src/impl_ops_mul.rs
+++ b/src/impl_ops_mul.rs
@@ -30,15 +30,15 @@ impl<'a> Mul<&'a BigDecimal> for BigDecimal {
if self.is_one() {
self.scale = rhs.scale;
self.int_val.set_zero();
- s... | 1 | 7 | 7 |
246b91abbc9b263e172e3100f3bc816d9c0186b6 | Andrew Kubera | 2024-01-15T22:27:44 | Allow clippy float-comparisons in division impl | diff --git a/src/impl_ops.rs b/src/impl_ops.rs
index 565d94b..b7afec1 100644
--- a/src/impl_ops.rs
+++ b/src/impl_ops.rs
@@ -356,6 +356,7 @@ macro_rules! impl_div_for_primitive {
impl Div<$t> for BigDecimal {
type Output = BigDecimal;
+ #[allow(clippy::float_cmp)]
fn div(... | 1 | 1 | 0 |
fbb947b435df0519da9fe3d9fb2f4569db492b80 | Andrew Kubera | 2024-01-16T04:00:38 | Allow some clippy violations | diff --git a/src/lib.rs b/src/lib.rs
index 46a3a38..f0779f3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -41,11 +41,14 @@
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::style)]
+#![allow(clippy::excessive_precision)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::needless_return)]
#![a... | 1 | 3 | 0 |
332db69163261cdb8b3eab49c349b2065e21ab5e | Andrew Kubera | 2024-01-16T03:50:57 | Fix clippy warnings in examples | diff --git a/examples/floating-precision.rs b/examples/floating-precision.rs
index 2813a1e..14f4e8f 100644
--- a/examples/floating-precision.rs
+++ b/examples/floating-precision.rs
@@ -4,7 +4,7 @@ use bigdecimal::BigDecimal;
use std::str::FromStr;
fn main() {
- let input = std::env::args().skip(1).next().unwrap_... | 2 | 3 | 3 |
8355022a303a552568899d62cb70b8eef434b303 | Andrew Kubera | 2024-01-16T01:51:43 | Replace serde_json with serde_test | diff --git a/Cargo.toml b/Cargo.toml
index 6fdfbea..50c9dfd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,7 +28,7 @@ serde = { version = "1.0", optional = true, default-features = false }
[dev-dependencies]
paste = "1"
-serde_json = "<1.0.101"
+serde_test = "<1.0.176"
siphasher = { version = "0.3.10", default-fe... | 3 | 69 | 64 |
909062bb8b9338e26d3a9b7b911c551dda93f100 | Andrew Kubera | 2024-01-15T00:55:46 | Rewrite serde tests using macros | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
index 58aabb4..ed5a179 100644
--- a/src/impl_serde.rs
+++ b/src/impl_serde.rs
@@ -4,8 +4,6 @@
use crate::*;
use serde::{de, ser};
-#[allow(unused_imports)]
-use num_traits::FromPrimitive;
impl ser::Serialize for BigDecimal {
fn serialize<S>(&self, serialize... | 1 | 101 | 73 |
b86dfc3fa189951cd2b9fdacc4521530bc5dd6a1 | tenuous-guidance | 2023-11-03T19:12:57 | Move serde implementation into impl_serde.rs | diff --git a/src/impl_serde.rs b/src/impl_serde.rs
new file mode 100644
index 0000000..58aabb4
--- /dev/null
+++ b/src/impl_serde.rs
@@ -0,0 +1,164 @@
+//!
+//! Support for serde implementations
+//!
+use crate::*;
+use serde::{de, ser};
+
+#[allow(unused_imports)]
+use num_traits::FromPrimitive;
+
+impl ser::Serialize... | 2 | 168 | 165 |
f3406a7cb9cec69e7e231bcaa4d142215247aab1 | Andrew Kubera | 2024-01-14T22:05:14 | Add comment on where to find real implementation | diff --git a/src/impl_trait_from_str.rs b/src/impl_trait_from_str.rs
index 7e8de01..4dd760f 100644
--- a/src/impl_trait_from_str.rs
+++ b/src/impl_trait_from_str.rs
@@ -6,6 +6,7 @@ impl FromStr for BigDecimal {
#[inline]
fn from_str(s: &str) -> Result<BigDecimal, ParseBigDecimalError> {
+ // implemen... | 1 | 1 | 0 |
d749306315f26f38d891fb15669e3e7aad92fb69 | Andrew Kubera | 2024-01-14T22:02:11 | Move invalid-str tests to impl_trait_from_str | diff --git a/src/impl_trait_from_str.rs b/src/impl_trait_from_str.rs
index 112f2f5..7e8de01 100644
--- a/src/impl_trait_from_str.rs
+++ b/src/impl_trait_from_str.rs
@@ -44,4 +44,36 @@ mod tests {
impl_case!(case_999d521_939: "999.521_939" => 999521939 E -6);
impl_case!(case_679d35_84_03en2: "679.35_84_03E-2" ... | 2 | 32 | 41 |
7b926e484b5cbcc99dc478a9437b40a8ee2300a4 | Andrew Kubera | 2024-01-14T21:48:35 | Move tests to impl_trait_from_str | diff --git a/src/impl_trait_from_str.rs b/src/impl_trait_from_str.rs
index 7f8538b..112f2f5 100644
--- a/src/impl_trait_from_str.rs
+++ b/src/impl_trait_from_str.rs
@@ -9,3 +9,39 @@ impl FromStr for BigDecimal {
BigDecimal::from_str_radix(s, 10)
}
}
+
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ ... | 2 | 36 | 30 |
064e880e86d183a43f9e91ab2280fd29ea74f544 | Andrew Kubera | 2024-01-14T21:35:44 | Move FromStr impl to separate file | diff --git a/src/impl_trait_from_str.rs b/src/impl_trait_from_str.rs
new file mode 100644
index 0000000..7f8538b
--- /dev/null
+++ b/src/impl_trait_from_str.rs
@@ -0,0 +1,11 @@
+use crate::*;
+use stdlib::str::FromStr;
+
+impl FromStr for BigDecimal {
+ type Err = ParseBigDecimalError;
+
+ #[inline]
+ fn from_... | 2 | 12 | 9 |
8ebccee0a0e1bbb2c7b5b0bb25c6ae829036d25c | LinFeng | 2024-01-14T22:39:27 | Remove unnecessary copy in add_refs_into | diff --git a/src/context.rs b/src/context.rs
index c48cc84..32beda9 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -128,9 +128,7 @@ impl Context {
A: Into<BigDecimalRef<'a>>,
B: Into<BigDecimalRef<'b>>,
{
- let a = a.into();
- let b = b.into();
- let sum = a.to_owned() +... | 1 | 1 | 3 |
351411addce5018f6808e85ad7a3460993e81340 | Andrew Kubera | 2023-10-16T06:55:55 | Begin v0.4.3 development | diff --git a/Cargo.toml b/Cargo.toml
index 49bd37e..6fdfbea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.4.2"
+version = "0.4.3+dev"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
a2ec320504fea2105f3d3edd362566b3213f67b6 | Andrew Kubera | 2023-10-16T06:40:13 | Version 0.4.2 | diff --git a/Cargo.toml b/Cargo.toml
index 85556b6..49bd37e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.4.2+dev"
+version = "0.4.2"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
d6e992a8ef6cb61cdcb66c6c8366578004304800 | Andrew Kubera | 2023-10-16T06:17:28 | Fix clippy lints | diff --git a/src/impl_num.rs b/src/impl_num.rs
index 53dadab..8136973 100644
--- a/src/impl_num.rs
+++ b/src/impl_num.rs
@@ -183,7 +183,7 @@ mod test {
#[test]
fn out_of_bounds() {
let d = BigDecimal::from_str_radix("1e-9223372036854775808", 10);
- assert_eq!(d.unwrap_err(), Pa... | 3 | 5 | 13 |
ff1def45582178fd3f87456701437819cf7fc224 | Andrew Kubera | 2023-10-16T06:13:23 | Fix panic in from_str_radix
Reported-By: fritzrehde (github-issue #115) | diff --git a/src/impl_num.rs b/src/impl_num.rs
index 4953cd1..53dadab 100644
--- a/src/impl_num.rs
+++ b/src/impl_num.rs
@@ -85,7 +85,15 @@ impl Num for BigDecimal {
}
};
- let scale = decimal_offset - exponent_value;
+ let scale = match decimal_offset.checked_sub(exponent_value) {... | 1 | 26 | 1 |
f0ad6c329997a0a5ad299ccee19e0257364a9700 | Andrew Kubera | 2023-10-16T05:38:16 | Fix Rust 1.43 and no-std compatibility issues | diff --git a/src/arithmetic/inverse.rs b/src/arithmetic/inverse.rs
index b209f07..398463e 100644
--- a/src/arithmetic/inverse.rs
+++ b/src/arithmetic/inverse.rs
@@ -49,7 +49,7 @@ fn make_inv_guess(bit_count: u64, scale: i64) -> BigDecimal {
let magic_factor = stdlib::f64::consts::LN_2;
let bit_count = bit_c... | 2 | 7 | 6 |
f298d80907a7d11e53cc569e3911dde3e97ce222 | Andrew Kubera | 2023-10-16T05:03:49 | Standardize division of BigDecimal by primitive integer | diff --git a/src/impl_ops.rs b/src/impl_ops.rs
index 9cac1be..565d94b 100644
--- a/src/impl_ops.rs
+++ b/src/impl_ops.rs
@@ -304,7 +304,7 @@ macro_rules! impl_div_for_primitive {
type Output = BigDecimal;
fn div(self, denom: &BigDecimal) -> BigDecimal {
- BigDecimal::from(self... | 2 | 13 | 1 |
9673b530f881818f338863f707418f5425d7cb14 | Andrew Kubera | 2023-10-16T04:09:31 | Add tests for make_inv_guess | diff --git a/src/arithmetic/inverse.rs b/src/arithmetic/inverse.rs
index 429971e..b209f07 100644
--- a/src/arithmetic/inverse.rs
+++ b/src/arithmetic/inverse.rs
@@ -17,6 +17,7 @@ pub(crate) fn impl_inverse_uint_scale(n: &BigUint, scale: i64, ctx: &Context) ->
// calculate first iteration
let mut running_res... | 1 | 78 | 1 |
de1e59f1194740149312d3c25e236860b98d455a | Andrew Kubera | 2023-10-16T04:08:31 | Reimplement make_inv_guess | diff --git a/src/arithmetic/inverse.rs b/src/arithmetic/inverse.rs
index e291707..429971e 100644
--- a/src/arithmetic/inverse.rs
+++ b/src/arithmetic/inverse.rs
@@ -41,23 +41,33 @@ pub(crate) fn impl_inverse_uint_scale(n: &BigUint, scale: i64, ctx: &Context) ->
return result;
}
+
+/// guess inverse based on the... | 1 | 20 | 10 |
e72a677b1a852d9307f4663d557b70077ad105d6 | Andrew Kubera | 2023-10-16T02:51:57 | Support subnormal floating point values | diff --git a/src/parsing.rs b/src/parsing.rs
index 8bd917b..83d5ed6 100644
--- a/src/parsing.rs
+++ b/src/parsing.rs
@@ -17,7 +17,7 @@ pub(crate) fn try_parse_from_f32(n: f32) -> Result<BigDecimal, ParseBigDecimalEr
match n.classify() {
Nan => Err(ParseBigDecimalError::Other("NAN".into())),
Infin... | 3 | 73 | 4 |
942ff2276a497bd29d4f08c26862b22e1991adf7 | Andrew Kubera | 2023-10-15T19:08:00 | Remove unnecessary property-test scale assumption | diff --git a/src/impl_ops_sub.rs b/src/impl_ops_sub.rs
index a640063..619bd4f 100644
--- a/src/impl_ops_sub.rs
+++ b/src/impl_ops_sub.rs
@@ -310,7 +310,6 @@ mod test {
// ignore non-normal numbers
prop_assume!(f.is_normal());
prop_assume!(g.is_normal());
- ... | 1 | 0 | 1 |
64885ac2897735c463bcc41738de068e8737dc6f | Andrew Kubera | 2023-10-15T18:59:47 | Add borrow to stdlib and use ToOwned in impl_ops_add | diff --git a/src/impl_ops_add.rs b/src/impl_ops_add.rs
index 4a02747..f3cba79 100644
--- a/src/impl_ops_add.rs
+++ b/src/impl_ops_add.rs
@@ -2,6 +2,7 @@
//!
use super::*;
+use stdlib::borrow::ToOwned;
impl Add<BigDecimal> for BigDecimal {
diff --git a/src/with_std.rs b/src/with_std.rs
index 4ae185b..ace3082 10... | 3 | 3 | 0 |
61d1c631bd34b30f25274fe42c93c631bb41a4fd | Andrew Kubera | 2023-10-15T18:51:38 | Revert "Remove pub modifier from rounding mod"
This reverts commit 4a772f5346744200baf4da2084e42f9f68f97795. | diff --git a/src/lib.rs b/src/lib.rs
index 2d9bf82..e461a6a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -116,7 +116,7 @@ mod impl_num;
mod parsing;
// Routines for rounding
-mod rounding;
+pub mod rounding;
pub use rounding::RoundingMode;
// Mathematical context | 1 | 1 | 1 |
7df7febb6f4a257004bedd8f8e80a7a50cfcd32e | Andrew Kubera | 2023-10-15T18:51:27 | Remove impl From<BigDecimalRef> for BigDecimal | diff --git a/src/lib.rs b/src/lib.rs
index 878b06c..2d9bf82 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1352,12 +1352,6 @@ impl<'a> From<&'a BigInt> for BigDecimalRef<'a> {
}
}
-impl<'a> From<BigDecimalRef<'a>> for BigDecimal {
- fn from(n: BigDecimalRef<'a>) -> Self {
- n.to_owned()
- }
-}
-
/... | 1 | 0 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.