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 |
|---|---|---|---|---|---|---|---|
99bf9b3401e29e4dab8e12853dda1e84da8c5864 | Andrew Kubera | 2023-03-20T03:24:38 | Handle case where highest digit is left of rounding point | diff --git a/src/lib.rs b/src/lib.rs
index 1338fc7..3400ff4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -617,23 +617,55 @@ impl BigDecimal {
/// Return number rounded to round_digits precision after the decimal point
pub fn round(&self, round_digits: i64) -> BigDecimal {
- let (bigint, decimal_part_d... | 1 | 41 | 9 |
ded4e6427b894ee4c0bebfa27b64cb103f5af7f9 | Andrew Kubera | 2023-03-20T01:20:59 | Reimplement round using to_radix_le(100) | diff --git a/src/lib.rs b/src/lib.rs
index 0fe0380..1338fc7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -623,22 +623,56 @@ impl BigDecimal {
return self.clone();
}
- let mut number = bigint.clone();
- if number < BigInt::zero() {
- number = -number;
- }
- f... | 1 | 48 | 14 |
82ddc5e70076a7d188009b186dfb4c99dfc4855a | Andrew Kubera | 2023-03-20T00:05:39 | Add test for rounding large numbers | diff --git a/src/lib.rs b/src/lib.rs
index a7e0265..0fe0380 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2828,6 +2828,17 @@ mod bigdecimal_tests {
}
}
+ #[test]
+ fn round_large_number() {
+ use super::BigDecimal;
+
+ let z = BigDecimal::from_str("3.4613133327063255443352353815722045... | 1 | 11 | 0 |
822d91b85e1617d572f90024e82b43a4b2729b7b | Andrew Kubera | 2023-05-21T20:12:05 | Fix warnings in without_std.rs | diff --git a/src/without_std.rs b/src/without_std.rs
index c42a921..b05b5d3 100644
--- a/src/without_std.rs
+++ b/src/without_std.rs
@@ -22,9 +22,11 @@ use siphasher::sip::SipHasher as DefaultHasher;
// Without this import we get the following error:
// error[E0599]: no method named `powi` found for type `f64` in t... | 1 | 3 | 1 |
3d22823a66d4b079d97036d43e92e4ea6592ff2e | Andrew Kubera | 2023-05-21T04:52:49 | Remove alloc feature | diff --git a/Cargo.toml b/Cargo.toml
index 6f93866..9925b59 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,6 +31,5 @@ siphasher = { version = "0.3.10", default-features = false }
[features]
default = ["std"]
-alloc = []
string-only = []
std = ["num-bigint/std", "num-integer/std", "num-traits/std"]
diff --git a/s... | 2 | 1 | 4 |
4a8e9e09417ae33c200cca852a1f8f94ab2b3ea5 | Andrew Kubera | 2023-05-21T04:35:08 | Replace std usages with crate | diff --git a/src/lib.rs b/src/lib.rs
index 349bbf5..a7e0265 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2138,13 +2138,10 @@ mod bigdecimal_serde {
#[rustfmt::skip]
#[cfg(test)]
mod bigdecimal_tests {
- use crate::{BigDecimal, FromStr, TryFrom};
+ use crate::{BigDecimal, ToString, FromStr, TryFrom};
use n... | 4 | 26 | 34 |
2ca8605b3c13b998c75cc68df98eabeac5131aa2 | Andrew Kubera | 2023-05-12T22:09:45 | Move with_alloc.rs behavior into without_std.rs | diff --git a/src/lib.rs b/src/lib.rs
index 28c9d5c..349bbf5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -60,9 +60,6 @@ include!("./with_std.rs");
#[cfg(not(feature = "std"))]
include!("./without_std.rs");
-#[cfg(all(not(feature = "std"), feature = "alloc"))]
-include!("./with_alloc.rs");
-
use crate::cmp::Ordering... | 3 | 7 | 6 |
7e75dcdd0e99e3f93ba490329dcbad03a6e00ee1 | Andrew Kubera | 2023-05-10T01:50:31 | Replace std::mem::swap with crate::mem::swap | diff --git a/src/lib.rs b/src/lib.rs
index 8863e54..28c9d5c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1316,7 +1316,7 @@ impl Mul<BigDecimal> for BigInt {
fn mul(mut self, mut rhs: BigDecimal) -> BigDecimal {
if rhs.is_one() {
rhs.scale = 0;
- std::mem::swap(&mut rhs.int_val, &mu... | 3 | 3 | 1 |
805d73ccccd1ed1f0b61fdb169dac556d5ea20db | Andrew Kubera | 2023-05-10T01:49:14 | Verticalize long import lists | diff --git a/src/with_std.rs b/src/with_std.rs
index 443c644..2226e59 100644
--- a/src/with_std.rs
+++ b/src/with_std.rs
@@ -1,4 +1,19 @@
-use std::{cmp, convert, default, fmt, hash, num, ops, iter, str, string, i8, f32, f64};
+use std::{
+ cmp,
+ convert,
+ default,
+ fmt,
+ hash,
+ num,
+ ops,
+ ... | 2 | 30 | 2 |
4de5d3e9dadeb28b0527b65a578c5e032e77227e | Andrew Kubera | 2023-05-12T06:12:06 | Run rustfmt on src/lib.rs | diff --git a/src/lib.rs b/src/lib.rs
index cb6e198..8863e54 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1324,7 +1324,6 @@ impl Mul<BigDecimal> for BigInt {
}
}
-
impl<'a> Mul<BigDecimal> for &'a BigInt {
type Output = BigDecimal;
@@ -1344,7 +1343,6 @@ impl<'a> Mul<BigDecimal> for &'a BigInt {
}
}... | 1 | 0 | 5 |
2ee012106c623746510e979263f503626e370346 | Andrew Kubera | 2023-05-10T03:45:10 | Add bignum to cargo keywords | diff --git a/Cargo.toml b/Cargo.toml
index 18cb408..6f93866 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ repository = "https://github.com/akubera/bigdecimal-rs"
keywords = [
"mathematics",
"numerics",
+ "bignum",
"decimal",
"arbitrary-precision",
"floating-point", | 1 | 1 | 0 |
4ba6fb1aaa1445689101818b2bfdb6d900e08672 | Andrew Kubera | 2023-05-10T03:39:58 | Remove serde/std from std feature | diff --git a/Cargo.toml b/Cargo.toml
index d0392e8..18cb408 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,4 +32,4 @@ siphasher = { version = "0.3.10", default-features = false }
default = ["std"]
alloc = []
string-only = []
-std = ["num-bigint/std", "num-integer/std", "num-traits/std", "serde/std"]
+std = ["num-bi... | 1 | 1 | 1 |
d47d366cbe572e831fde9d74871ebc922a91ecea | Big Herc | 2023-02-24T00:45:06 | Feature: add support for `no_std` environments | diff --git a/Cargo.toml b/Cargo.toml
index 115585a..d0392e8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,18 +6,30 @@ description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal"
homepage = "https://github.com/akubera/bigdecimal-rs"
repository = "https://github.com/akubera/bigdec... | 5 | 97 | 46 |
177c0913c88090132465af2a2875badf3ba85568 | Andrew Kubera | 2023-05-21T00:14:21 | Use parse_from_f64 in BigDecimal::try_from<f64> | diff --git a/src/lib.rs b/src/lib.rs
index c678cc3..0565f5b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1918,7 +1918,7 @@ impl TryFrom<f64> for BigDecimal {
#[inline]
fn try_from(n: f64) -> Result<Self, Self::Error> {
- BigDecimal::from_str(&format!("{:.PRECISION$e}", n, PRECISION = ::std::f64::DIGI... | 1 | 7 | 8 |
4739e145cbfa573bf6a6b8e2380e8dee0f676e3a | Andrew Kubera | 2023-05-21T00:10:33 | Fix parsing negative zero floating point values | diff --git a/src/parsing.rs b/src/parsing.rs
index 91c5e53..7337e30 100644
--- a/src/parsing.rs
+++ b/src/parsing.rs
@@ -53,7 +53,7 @@ pub(crate) fn parse_from_f32(n: f32) -> BigDecimal {
let bits = n.to_bits();
- if bits == 0 {
+ if (bits << 1) == 0 {
return BigDecimal {
int_val: B... | 3 | 5 | 2 |
d82ab14d5c646388b70a55edc15b2a1d259a890f | Andrew Kubera | 2023-05-20T23:45:26 | Add parse_from_f64 to parsing.rs | diff --git a/src/parsing.rs b/src/parsing.rs
index 3997e46..91c5e53 100644
--- a/src/parsing.rs
+++ b/src/parsing.rs
@@ -103,3 +103,103 @@ mod test_parse_from_f32 {
include!("parsing.tests.parse_from_f32.rs");
}
+
+
+/// Try creating bigdecimal from f64
+///
+/// Non "normal" values will return Error case
+///
... | 1 | 100 | 0 |
6f26bdef3c0cc7a5005027eb260476dd8b98c579 | Andrew Kubera | 2023-05-20T23:43:56 | Add parse_from_f64 tests | diff --git a/src/parsing.tests.parse_from_f32.rs b/src/parsing.tests.parse_from_f32.rs
index 16ed80c..89b6727 100644
--- a/src/parsing.tests.parse_from_f32.rs
+++ b/src/parsing.tests.parse_from_f32.rs
@@ -1,4 +1,4 @@
-// tests for function bigdecimal::parsing::parse_from_f23
+// tests for function bigdecimal::parsing::... | 2 | 103 | 1 |
5824b8462796f2fd81375133825af34e8b7ced85 | Andrew Kubera | 2023-05-20T06:10:45 | Fix and add cases to test_from_f32 | diff --git a/src/lib.rs b/src/lib.rs
index f9ab1f6..c678cc3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2137,7 +2137,7 @@ mod bigdecimal_tests {
BigDecimal::from_f32(0.001).unwrap(),
];
- let expected_sum = BigDecimal::from_str("2.80100001196842640638351440429688").unwrap();
+ let... | 1 | 7 | 8 |
f3d56c202536dbafffea0517891dca007f0d979d | Andrew Kubera | 2023-05-20T05:55:55 | Add more tests for parse_from_f32 | diff --git a/src/parsing.tests.parse_from_f32.rs b/src/parsing.tests.parse_from_f32.rs
index 8a85b33..16ed80c 100644
--- a/src/parsing.tests.parse_from_f32.rs
+++ b/src/parsing.tests.parse_from_f32.rs
@@ -9,22 +9,29 @@ macro_rules! impl_test {
paste! {
#[test]
fn [< case $name >]() {
... | 1 | 13 | 3 |
57c90ee5bd93b1fa4dff45d44da37dc3f11fb215 | Andrew Kubera | 2023-05-20T05:51:31 | Fix case where power could be positive when calculating shift | diff --git a/src/parsing.rs b/src/parsing.rs
index 940dcdf..3997e46 100644
--- a/src/parsing.rs
+++ b/src/parsing.rs
@@ -71,11 +71,13 @@ pub(crate) fn parse_from_f32(n: f32) -> BigDecimal {
scale = 0;
}
Less => {
- let trailing_zeros = frac.trailing_zeros();
- let re... | 1 | 5 | 3 |
5057da6ae963160b1f9658a8dcfae3d73cf105cd | Andrew Kubera | 2023-05-21T00:17:37 | Factor f32 parsing into split_f32_into_parts | diff --git a/src/parsing.rs b/src/parsing.rs
index 0b2fd1d..940dcdf 100644
--- a/src/parsing.rs
+++ b/src/parsing.rs
@@ -20,6 +20,30 @@ pub(crate) fn try_parse_from_f32(n: f32) -> Result<BigDecimal, ParseBigDecimalEr
}
+/// Return mantissa, exponent, and sign of given floating point number
+///
+/// ```math
+/// f... | 1 | 26 | 11 |
e9a51bd02eed46d2b653a608c2c4c66ba562466c | Andrew Kubera | 2023-05-21T00:17:36 | Fix expected values in bigdecimal_tests::sum tests | diff --git a/src/lib.rs b/src/lib.rs
index 4fdc8d4..f9ab1f6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2137,7 +2137,7 @@ mod bigdecimal_tests {
BigDecimal::from_f32(0.001).unwrap(),
];
- let expected_sum = BigDecimal::from_f32(2.8009998798370361328125).unwrap();
+ let expected_su... | 1 | 2 | 4 |
6d5f33bbc980538aa908268c5fbefeea20bac662 | Andrew Kubera | 2023-05-21T00:17:35 | Use try_parse_from_f32 in try_from::<f32> and update tests | diff --git a/src/lib.rs b/src/lib.rs
index 0429b0b..4fdc8d4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1909,7 +1909,7 @@ impl TryFrom<f32> for BigDecimal {
#[inline]
fn try_from(n: f32) -> Result<Self, Self::Error> {
- parsing::parse_from_f32(n)
+ parsing::try_parse_from_f32(n)
}
}
@... | 1 | 7 | 6 |
8ae0f5763fb1fa3b376859032ad5bd3eda63c6d7 | Andrew Kubera | 2023-05-21T00:17:30 | Revert serde_json dependency to 0.9 | diff --git a/Cargo.toml b/Cargo.toml
index 6c31be1..115585a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,9 +17,7 @@ serde = { version = "1.0", optional = true }
[dev-dependencies]
paste = "*"
-
-[dev-dependencies.serde_json]
-version = "1.0"
+serde_json = { version = "0.9" }
[features]
string-only = [] | 1 | 1 | 3 |
efddbd2fb1cab7c2f7e070399d1816ea497690e0 | Andrew Kubera | 2023-05-21T00:17:29 | Split try_parse_from_f32 behavior from parse_from_f32 | diff --git a/src/parsing.rs b/src/parsing.rs
index ec05316..0b2fd1d 100644
--- a/src/parsing.rs
+++ b/src/parsing.rs
@@ -5,23 +5,35 @@ use super::{BigDecimal, ParseBigDecimalError};
use num_bigint::{BigInt, BigUint, Sign};
-pub(crate) fn parse_from_f32(n: f32) -> Result<BigDecimal, ParseBigDecimalError> {
+/// Try... | 1 | 28 | 18 |
9c064a21649c3a789a2028855be698a085ec69ed | Andrew Kubera | 2023-05-21T00:17:14 | Rewrite parse_from_f32 tests with macros | diff --git a/src/parsing.tests.parse_from_f32.rs b/src/parsing.tests.parse_from_f32.rs
index bfd1901..8a85b33 100644
--- a/src/parsing.tests.parse_from_f32.rs
+++ b/src/parsing.tests.parse_from_f32.rs
@@ -1,103 +1,99 @@
-
-
-#[test]
-fn case_45En1() {
- let n = 4.5f32;
- let d = parse_from_f32(n);
- assert_eq!... | 1 | 65 | 69 |
6b7bbafe79e0e2e8dc2720b917f9867cec254e0c | Andrew Kubera | 2023-05-21T00:17:13 | Add paste dev dependency | diff --git a/Cargo.toml b/Cargo.toml
index e9db4f7..6c31be1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,6 +15,9 @@ num-integer = "0.1"
num-traits = "0.2"
serde = { version = "1.0", optional = true }
+[dev-dependencies]
+paste = "*"
+
[dev-dependencies.serde_json]
version = "1.0"
diff --git a/src/lib.rs b/sr... | 2 | 6 | 0 |
0bf42b13519c273948c53ebc8001a0878b06d58a | Andrew Kubera | 2023-05-21T00:17:49 | Add test cases for parse_from_f32 | diff --git a/src/parsing.tests.parse_from_f32.rs b/src/parsing.tests.parse_from_f32.rs
new file mode 100644
index 0000000..bfd1901
--- /dev/null
+++ b/src/parsing.tests.parse_from_f32.rs
@@ -0,0 +1,103 @@
+
+
+#[test]
+fn case_45En1() {
+ let n = 4.5f32;
+ let d = parse_from_f32(n);
+ assert_eq!(d, "4.5".parse... | 1 | 103 | 0 |
1798a5ca204e3ce6713aa6e18823dc0ec3c65aeb | Andrew Kubera | 2023-05-21T00:15:53 | Move TryFrom<f32> implementation to parsing module | diff --git a/src/lib.rs b/src/lib.rs
index be41db7..d7de11c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -74,6 +74,8 @@ const LOG2_10: f64 = 3.321928094887362_f64;
#[macro_use]
mod macros;
+mod parsing;
+
#[inline(always)]
fn ten_to_the(pow: u64) -> BigInt {
if pow < 20 {
@@ -1904,7 +1906,7 @@ impl TryFrom<f3... | 2 | 81 | 1 |
d6579e57c998419f1b939ad5918109c6e4973545 | Andrew Kubera | 2023-05-12T02:51:26 | Add more test cases to test_from_str | diff --git a/src/lib.rs b/src/lib.rs
index fbbef79..be41db7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3038,12 +3038,17 @@ mod bigdecimal_tests {
("1.23E+3", 123, -1),
("1.23E-8", 123, 10),
("-1.23E-10", -123, 12),
+ ("123_", 123, 0),
+ ("31_862_140.830_686... | 1 | 6 | 1 |
7cbee8e75016cb5100f458592237d251bb32e1e2 | Daniel Bauman | 2023-05-10T19:21:01 | Fix incorrect handling of _ in decimal
BigDecimal supports '_' chars as visual
seperators in number strings in the pre and
post "." parts of the number.
The counting of post "." digits however
counts all characters but it should exclude '_' chars.
The underscore support comes from BigDecimal's use of num-bigint
http... | diff --git a/src/lib.rs b/src/lib.rs
index 037cd0c..fbbef79 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1792,7 +1792,10 @@ impl Num for BigDecimal {
// copy all trailing characters after '.' into the digits string
digits.push_str(trail);
- (digits, trail.len() as i64)... | 1 | 5 | 1 |
cf4f850476ae3ab09d1b2c99abc8468fd3e4bacf | Young | 2022-07-16T07:05:01 | override to_u128 for BigDecimal | diff --git a/src/lib.rs b/src/lib.rs
index 3b1d625..037cd0c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1823,6 +1823,13 @@ impl ToPrimitive for BigDecimal {
Sign::Minus => None,
}
}
+ fn to_u128(&self) -> Option<u128> {
+ match self.sign() {
+ Sign::Plus => self.with_sca... | 1 | 7 | 0 |
0596dbe0bfb47a62e5ba45102be85404befb1de3 | Young | 2022-07-16T07:04:49 | write a test case for to_u128 which will fail | diff --git a/src/lib.rs b/src/lib.rs
index 0db5198..3b1d625 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2177,6 +2177,22 @@ mod bigdecimal_tests {
}
}
+ #[test]
+ fn test_to_u128() {
+ let vals = vec![
+ ("340282366920938463463374607431768211455", 34028236692093846346337460743176... | 1 | 16 | 0 |
79cf57ece5e5a8307bb3a7cbf2d13dfacbec40bd | Young | 2022-07-16T07:02:25 | add negative max case | diff --git a/src/lib.rs b/src/lib.rs
index fc5f02d..0db5198 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2163,10 +2163,11 @@ mod bigdecimal_tests {
#[test]
fn test_to_i128() {
let vals = vec![
+ ("170141183460469231731687303715884105727", 170141183460469231731687303715884105727),
+ ... | 1 | 2 | 1 |
c189292c99c325d53db7eb50afdfc4389c1a7a45 | Young | 2022-07-16T06:59:54 | override to_i128 for BigDecimal to pass the test | diff --git a/src/lib.rs b/src/lib.rs
index c5be214..fc5f02d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1810,6 +1810,12 @@ impl ToPrimitive for BigDecimal {
Sign::NoSign => Some(0),
}
}
+ fn to_i128(&self) -> Option<i128> {
+ match self.sign() {
+ Sign::Minus | Sign::Plu... | 1 | 6 | 0 |
a125441941da8386773f203dc8441bf96bcd06a2 | Young | 2022-07-16T06:59:19 | write a test for to_i128 which will be failred | diff --git a/src/lib.rs b/src/lib.rs
index 4ec8998..c5be214 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2154,6 +2154,22 @@ mod bigdecimal_tests {
}
}
+ #[test]
+ fn test_to_i128() {
+ let vals = vec![
+ ("12.34", 12),
+ ("3.14", 3),
+ ("50", 50),
+ ... | 1 | 16 | 0 |
7d928f5e2e501ec64066ebf1f7725912d5107cad | Young | 2022-07-16T06:46:31 | fix typos | diff --git a/src/lib.rs b/src/lib.rs
index 7c79e95..4ec8998 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1673,7 +1673,7 @@ impl<'a> Sum<&'a BigDecimal> for BigDecimal {
impl fmt::Display for BigDecimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- // Aquire the absolute integer as a decimal ... | 1 | 1 | 1 |
31f5c1147189622c8150a9ee95387597c64028e2 | Andrew Kubera | 2021-08-26T21:45:39 | Begin v0.4.0 development branch | diff --git a/Cargo.toml b/Cargo.toml
index b8fc329..e9db4f7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.3.1"
+version = "0.4.0+dev"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
526007aec0411b61afd9a8d83206eb21d833c6a5 | Andrew Kubera | 2023-03-17T05:49:03 | Add missing combination impl Mul for BigDecimal and BigInt | diff --git a/src/lib.rs b/src/lib.rs
index 53660df..7c79e95 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1333,6 +1333,22 @@ impl<'a, 'b> Mul<&'a BigDecimal> for &'b BigInt {
}
}
+impl<'a> Mul<&'a BigDecimal> for BigInt {
+ type Output = BigDecimal;
+
+ #[inline]
+ fn mul(mut self, rhs: &BigDecimal) -> ... | 1 | 17 | 1 |
7d9ed4834410edba10e6077598bb123dbab0a07f | Andrew Kubera | 2023-03-17T05:45:45 | Add more multiplication test cases | diff --git a/src/lib.rs b/src/lib.rs
index c402d7e..53660df 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2315,7 +2315,7 @@ mod bigdecimal_tests {
}
}
- /// Test big decimal times big integer
+ /// Test multiplication between big decimal and big integer
#[test]
fn test_mul_bigint() {
... | 1 | 5 | 1 |
538fb3098b838bee7a85a5f90004aa49d0a36871 | Andrew Kubera | 2023-03-17T05:41:59 | Add MulAssign and Multiplication impls for BigInt | diff --git a/src/lib.rs b/src/lib.rs
index 9d814cf..c402d7e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1281,6 +1281,59 @@ impl<'a, 'b> Mul<&'a BigInt> for &'b BigDecimal {
}
}
+impl Mul<BigDecimal> for BigInt {
+ type Output = BigDecimal;
+
+ #[inline]
+ fn mul(mut self, mut rhs: BigDecimal) -> BigDe... | 1 | 72 | 0 |
6c3ac859c31da45fcf4e5ace605418633c372447 | Andrew Kubera | 2023-03-17T03:45:09 | Add new tests for multiplication | diff --git a/src/lib.rs b/src/lib.rs
index 66c1ba4..9d814cf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2210,6 +2210,7 @@ mod bigdecimal_tests {
}
}
+ /// Test multiplication of two bigdecimals
#[test]
fn test_mul() {
@@ -2220,6 +2221,10 @@ mod bigdecimal_tests {
("3", ".333... | 1 | 32 | 0 |
4b15264c326a825ecafc2f067da180a7e76e2c3f | Andrew Kubera | 2023-03-17T03:36:14 | Fix incorrect bigint source | diff --git a/src/lib.rs b/src/lib.rs
index 74a3921..66c1ba4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1273,7 +1273,7 @@ impl<'a, 'b> Mul<&'a BigInt> for &'b BigDecimal {
if rhs.is_one() {
self.normalized()
} else if self.is_one() {
- BigDecimal::new(self.int_val.clone(), 0)
... | 1 | 1 | 1 |
b003138381ada9b6735393ff62d8fa76ca7d8d12 | Andrew Kubera | 2023-03-17T03:19:13 | Add 1*x optimizations | diff --git a/src/lib.rs b/src/lib.rs
index 0c174a5..74a3921 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1178,9 +1178,15 @@ impl Mul<BigDecimal> for BigDecimal {
#[inline]
fn mul(mut self, rhs: BigDecimal) -> BigDecimal {
- self.scale += rhs.scale;
- self.int_val *= rhs.int_val;
- self
... | 1 | 40 | 10 |
53ed96556b31e2159912cfb70ac8e3d8ea018aa1 | Andrew Kubera | 2023-03-17T02:46:05 | Add test cases for round | diff --git a/src/lib.rs b/src/lib.rs
index 0ae823e..0c174a5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2600,11 +2600,16 @@ mod bigdecimal_tests {
("-9999.444455556666", 10, "-9999.4444555567"),
("-12345678987654321.123456789", 8, "-12345678987654321.12345679"),
("0.3333333333333... | 1 | 6 | 1 |
bd15d1473e85221732f6a9bdd13db50824065fef | Andrew Kubera | 2023-03-17T02:40:29 | Fix count_decimal_digits if value is negative | diff --git a/src/lib.rs b/src/lib.rs
index d445fd1..0ae823e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -100,10 +100,11 @@ fn count_decimal_digits(int: &BigInt) -> u64 {
if int.is_zero() {
return 1;
}
+ let uint = int.magnitude();
+ let mut digits = (uint.bits() as f64 / LOG2_10) as u64;
/... | 1 | 8 | 3 |
b6b81f46ef929e926f8c95f8dc6e26e254cd796e | Andrew Kubera | 2021-08-27T02:30:31 | Remove redundant clone | diff --git a/src/lib.rs b/src/lib.rs
index 642ba71..d445fd1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -732,7 +732,7 @@ impl FromStr for BigDecimal {
#[allow(deprecated)] // trim_right_match -> trim_end_match
impl Hash for BigDecimal {
fn hash<H: Hasher>(&self, state: &mut H) {
- let mut dec_str = self.i... | 1 | 1 | 1 |
32662d71b07f3e8b6f80cf206bbabd01f8da282d | Andrew Kubera | 2021-08-27T02:29:33 | Remove needless borrow | diff --git a/src/lib.rs b/src/lib.rs
index 37697b5..642ba71 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1402,7 +1402,7 @@ impl<'a, 'b> Div<&'b BigDecimal> for &'a BigDecimal {
let max_precision = 100;
- return impl_division(num_int.clone(), &den_int, scale, max_precision);
+ return impl_divi... | 1 | 1 | 1 |
c8ff1cbf3ad8216b79d610e44b4aeb4dc5f01ad6 | Andrew Kubera | 2021-08-27T02:29:11 | Replace chained ifs with cmp matches | diff --git a/src/lib.rs b/src/lib.rs
index 5a67682..37697b5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -802,14 +802,16 @@ impl PartialEq for BigDecimal {
#[inline]
fn eq(&self, rhs: &BigDecimal) -> bool {
// fix scale and test equality
- if self.scale > rhs.scale {
- let scaled_int... | 1 | 46 | 49 |
2544ce8fe491090128206f28ed736251f30496f5 | Andrew Kubera | 2021-08-27T02:22:02 | Ignore clippy::approx_constant | diff --git a/src/lib.rs b/src/lib.rs
index 96d7f7d..5a67682 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -68,6 +68,7 @@ use num_bigint::{BigInt, ParseBigIntError, Sign, ToBigInt};
use num_integer::Integer as IntegerTrait;
pub use num_traits::{FromPrimitive, Num, One, Signed, ToPrimitive, Zero};
+#[allow(clippy::appr... | 1 | 1 | 0 |
ca3f041719176993e6bf201acd4b3a33f68e4439 | Andrew Kubera | 2021-08-27T01:45:01 | Ignore clippy::match_like_matches_macro | diff --git a/src/lib.rs b/src/lib.rs
index 7108142..96d7f7d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -44,6 +44,7 @@
#![allow(clippy::suspicious_arithmetic_impl)]
#![allow(clippy::suspicious_op_assign_impl)]
#![allow(clippy::redundant_field_names)]
+#![allow(clippy::match_like_matches_macro)] // requires Rust 1.42... | 1 | 1 | 0 |
0871e2f276ae86dac5c6ca8afc7e44dd860aefed | Andrew Kubera | 2021-08-26T07:32:35 | Replace some comparison chains with match statements | diff --git a/src/lib.rs b/src/lib.rs
index e730447..7108142 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -193,34 +193,37 @@ impl BigDecimal {
return BigDecimal::new(BigInt::zero(), new_scale);
}
- if new_scale > self.scale {
- let scale_diff = new_scale - self.scale;
- ... | 1 | 43 | 38 |
0d718f9f73130cf88f53ead64587e9fd9bd9fcf8 | Andrew Kubera | 2021-08-26T21:54:24 | Begin v0.3.1 development branch | diff --git a/Cargo.toml b/Cargo.toml
index e17ad59..d41c7bc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.3.0"
+version = "0.3.1+dev"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
7d7aebc716e5f9f90d63d973a1a68d6398ce860b | Andrew Kubera | 2021-08-26T18:26:08 | Version 0.3.0 | diff --git a/Cargo.toml b/Cargo.toml
index 9a52150..e17ad59 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.2.2"
+version = "0.3.0"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
42c62ff18ea973c3fbe9d18959c3ed5fa92b059b | Andrew Kubera | 2021-08-26T18:25:47 | Bump num-bigint dependency to v0.4 | diff --git a/Cargo.toml b/Cargo.toml
index e1c7e61..9a52150 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ keywords = ["mathematics", "numerics", "decimal", "arbitrary-precision", "floati
license = "MIT/Apache-2.0"
[dependencies]
-num-bigint = "0.3"
+num-bigint = "0.4"
num-integer = "0.1"
num-traits =... | 1 | 1 | 1 |
e7bff2d09da073b06e27ee55d7ea638400b57f4c | Andrew Kubera | 2021-08-26T18:17:25 | Fix serde test suite | diff --git a/src/lib.rs b/src/lib.rs
index a59f148..8eb3dd6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1813,6 +1813,9 @@ mod bigdecimal_serde {
use serde::{de, ser};
use std::convert::TryFrom;
use std::fmt;
+ use std::str::FromStr;
+ #[allow(unused_imports)]
+ use num_traits::FromPrimitive;
... | 1 | 3 | 3 |
63eaee008923a0198866eacdfc579a39540de5b6 | Andrew Kubera | 2021-08-26T17:58:34 | Version 0.2.2 | diff --git a/Cargo.toml b/Cargo.toml
index 4675bb9..e1c7e61 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.2.1"
+version = "0.2.2"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
fe0ae06f84813b3ae2e0045364aeb605e8cbc4dd | Andrew Kubera | 2021-08-26T17:49:44 | Rollback num-bigint to version 0.3 | diff --git a/Cargo.toml b/Cargo.toml
index db91653..4675bb9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ keywords = ["mathematics", "numerics", "decimal", "arbitrary-precision", "floati
license = "MIT/Apache-2.0"
[dependencies]
-num-bigint = "0.4"
+num-bigint = "0.3"
num-integer = "0.1"
num-traits =... | 1 | 1 | 1 |
4df2605be62f3898c390e0a60a5a9f664ea488d9 | Andrew Kubera | 2021-08-26T17:46:01 | Expose dependent crates num-{bigint,traits} | diff --git a/src/lib.rs b/src/lib.rs
index 2e4f82e..a59f148 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -45,9 +45,10 @@
#![allow(clippy::suspicious_op_assign_impl)]
#![allow(clippy::redundant_field_names)]
-extern crate num_bigint;
+pub extern crate num_bigint;
+pub extern crate num_traits;
extern crate num_intege... | 1 | 6 | 9 |
6a5189f38ca399ebfd2eba71cdbb3955f42165dc | Andrew Kubera | 2021-08-26T07:05:35 | Version 0.2.1 | diff --git a/Cargo.toml b/Cargo.toml
index 0e17ea1..db91653 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.2.0"
+version = "0.2.1"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
f25732e5d9518e0cd3f8f70987ecef64795558ae | Andrew Kubera | 2021-08-26T06:39:48 | Apply rustfmt to repeated_squares example | diff --git a/examples/repeated_squares.rs b/examples/repeated_squares.rs
index d3d72cf..1269e78 100644
--- a/examples/repeated_squares.rs
+++ b/examples/repeated_squares.rs
@@ -1,13 +1,11 @@
-
extern crate bigdecimal;
use bigdecimal::BigDecimal;
use std::time::Instant;
use std::str::FromStr;
-fn main()
-{
- //... | 1 | 7 | 5 |
5bf04fd5d5180c0ff9e64a1b37011ec5a18a06f8 | Andrew Kubera | 2021-06-26T16:23:54 | Use global constant LOG2_10 in relevant places | diff --git a/src/lib.rs b/src/lib.rs
index eae11c6..2e4f82e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -98,7 +98,7 @@ fn count_decimal_digits(int: &BigInt) -> u64 {
return 1;
}
// guess number of digits based on number of bits in UInt
- let mut digits = (int.bits() as f64 / 3.3219280949) as u64;
... | 1 | 2 | 2 |
e0139117aba8e1344fc429a9a31712786142164c | Andrew Kubera | 2021-06-26T16:12:39 | Fix or allow clippy warnings | diff --git a/src/lib.rs b/src/lib.rs
index 7f1508f..eae11c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,6 +39,11 @@
//!
//! println!("Input ({}) with 10 decimals: {} vs {})", input, dec, float);
//! ```
+#![allow(clippy::unreadable_literal)]
+#![allow(clippy::needless_return)]
+#![allow(clippy::suspicious_arithm... | 2 | 22 | 16 |
9d63f148b411939b859810221893c849933c7c36 | Andrew Kubera | 2021-06-26T03:54:02 | Add more arithmetic examples to simple-math | diff --git a/examples/simple-math.rs b/examples/simple-math.rs
index c235bae..c4cab2d 100644
--- a/examples/simple-math.rs
+++ b/examples/simple-math.rs
@@ -9,11 +9,13 @@ Input (0.8) with 10 decimals: 0.8 vs 0.8)
square 0.64
From Prim: 3.300000000000000
match test 33.90000000000000
-sum: 58.00000000000000
-component... | 1 | 32 | 15 |
76be1a48901c96b99b53003a4c7b7acf47c10f81 | Andrew Kubera | 2021-06-26T03:41:47 | Add default output to simple-math example | diff --git a/examples/simple-math.rs b/examples/simple-math.rs
index 85fed98..c235bae 100644
--- a/examples/simple-math.rs
+++ b/examples/simple-math.rs
@@ -2,6 +2,20 @@ extern crate bigdecimal;
use bigdecimal::*;
use std::str::FromStr;
+/* Default example output:
+
+Hello, Big Decimals!
+Input (0.8) with 10 decima... | 1 | 14 | 0 |
1fcda3ee4662a9e3047920530490a50c3ef71b42 | Andrew Kubera | 2021-06-26T02:03:12 | Update num dependencies | diff --git a/Cargo.toml b/Cargo.toml
index 241f07b..0e17ea1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,8 +10,8 @@ keywords = ["mathematics", "numerics", "decimal", "arbitrary-precision", "floati
license = "MIT/Apache-2.0"
[dependencies]
-num-bigint = "0.3"
-num-integer = "0.1.43"
+num-bigint = "0.4"
+num-integ... | 1 | 2 | 2 |
02ba26b67a6a6bdfd9c941a11f19c0445c69b336 | David Briggs | 2020-09-10T22:50:05 | Rustfmt + fix panic on long fractions | diff --git a/src/lib.rs b/src/lib.rs
index 63c388b..8bf62bf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -52,9 +52,9 @@ use std::default::Default;
use std::error::Error;
use std::fmt;
use std::hash::{Hash, Hasher};
+use std::iter::Sum;
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{Add, AddAssign, D... | 1 | 18 | 21 |
fc797c302f4947e429cc331febc66fe3c7badc5e | Andrew Kubera | 2020-09-02T04:16:39 | Version 0.2.0 | diff --git a/Cargo.toml b/Cargo.toml
index b56c14f..241f07b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.1.2"
+version = "0.2.0"
authors = ["Andrew Kubera"]
description = "Arbitrary precision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
aa1982aa4c57dd5aac85a425c4612bc0d289ed2e | Andrew Kubera | 2020-09-02T04:15:20 | Make `round` a public method | diff --git a/src/lib.rs b/src/lib.rs
index 82a4475..63c388b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -586,7 +586,7 @@ impl BigDecimal {
}
/// Return number rounded to round_digits precision after the decimal point
- fn round(&self, round_digits: i64) -> BigDecimal {
+ pub fn round(&self, round_digi... | 1 | 1 | 1 |
734b34d50b869fa734e078ae8c6495e0b16013b0 | Andrew Kubera | 2020-09-02T04:12:38 | Update documentation to parse_bytes | diff --git a/src/lib.rs b/src/lib.rs
index 4115c50..82a4475 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -156,13 +156,16 @@ impl BigDecimal {
/// Creates and initializes a `BigDecimal`.
///
+ /// Decodes using `str::from_utf8` and forwards to `BigDecimal::from_str_radix`.
+ /// Only base-10 is supporte... | 1 | 4 | 1 |
60ea67a7f0a564320f05e5190c3c756260258937 | Leonardo Yvens | 2020-05-07T12:51:15 | Fix and rename normalize | diff --git a/src/lib.rs b/src/lib.rs
index d258a6e..50d87b9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -629,19 +629,17 @@ impl BigDecimal {
return result.with_prec(100);
}
- pub fn normalize(&self) -> BigDecimal {
- let (_, mut digits) = self.int_val.to_u32_digits();
- let mut trailing... | 1 | 17 | 12 |
46451ce2be9999ba039bb8d1b7695c592833c1a7 | Andrew Kubera | 2020-08-30T02:51:14 | Fix NAN in test | diff --git a/src/lib.rs b/src/lib.rs
index a103c77..d258a6e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2095,10 +2095,11 @@ mod bigdecimal_tests {
// assert_eq!(expected, n);
}
}
+
#[test]
fn test_nan_float() {
- assert!(BigDecimal::try_from(f32::NAN).is_err());
- ass... | 1 | 3 | 2 |
50286043b23823f321cb3744b86693d8b2cb4a45 | Andrew Kubera | 2020-08-30T02:20:12 | Update num dependencies | diff --git a/Cargo.toml b/Cargo.toml
index e12f1b4..b56c14f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,8 +10,8 @@ keywords = ["mathematics", "numerics", "decimal", "arbitrary-precision", "floati
license = "MIT/Apache-2.0"
[dependencies]
-num-bigint = "0.2"
-num-integer = "0.1.42"
+num-bigint = "0.3"
+num-integ... | 1 | 2 | 2 |
a00114bb8d6fe555f80c7575d6f8f8af27b3ffdf | Andrew Kubera | 2020-08-30T02:13:20 | Fix non-lexical lifetime error | diff --git a/src/lib.rs b/src/lib.rs
index 7396568..a103c77 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -631,12 +631,15 @@ impl BigDecimal {
pub fn normalize(&self) -> BigDecimal {
let (_, mut digits) = self.int_val.to_u32_digits();
- let mut digits_iter = digits.iter().rev();
let mut tr... | 1 | 7 | 4 |
742349433bbd4de3d0fd69e29c54454197d5552b | 吴翱翔 | 2020-06-27T14:56:00 | cargo clippy | diff --git a/src/lib.rs b/src/lib.rs
index 239d6b0..9ac280a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -600,12 +600,10 @@ impl BigDecimal {
if digit <= 4 {
self.with_scale(round_digits)
+ } else if bigint.is_negative() {
+ self.with_scale(round_digits) - BigDecimal::new(BigInt... | 1 | 3 | 5 |
1161ca93fe1432414d3b278accb4bf8f645bf2ec | 吴翱翔 | 2020-06-23T11:49:35 | Fix round() panic if self.digits() > 16 | diff --git a/src/lib.rs b/src/lib.rs
index 2ff353e..239d6b0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -582,7 +582,6 @@ impl BigDecimal {
}
/// Return number rounded to round_digits precision after the decimal point
- /// panic if self.digits() > 16
fn round(&self, round_digits: i64) -> BigDecimal ... | 1 | 5 | 5 |
42e4b85ba6509c10dd096323c6bd5215f4c14a87 | 吴翱翔 | 2020-06-22T14:07:34 | Add round implementation | diff --git a/src/lib.rs b/src/lib.rs
index dff4cee..2ff353e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -581,6 +581,35 @@ impl BigDecimal {
return result;
}
+ /// Return number rounded to round_digits precision after the decimal point
+ /// panic if self.digits() > 16
+ fn round(&self, round_di... | 1 | 56 | 0 |
dc660f2a65506d9b349cf091f053ea6284b4c570 | Denis Kolodin | 2020-05-28T20:59:33 | Fix TryFrom for the serde feature | diff --git a/src/lib.rs b/src/lib.rs
index 0c30143..7396568 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1798,6 +1798,7 @@ impl ToBigInt for BigDecimal {
mod bigdecimal_serde {
use super::BigDecimal;
use serde::{de, ser};
+ use std::convert::TryFrom;
use std::fmt;
impl ser::Serialize for BigDe... | 1 | 2 | 1 |
30b79b7601095e348eed845b116352f3feeb5fd0 | Denis Kolodin | 2020-05-28T20:41:51 | Use TryFrom for f32 and f64 | diff --git a/src/lib.rs b/src/lib.rs
index 1f5bdb3..0c30143 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -47,6 +47,7 @@ extern crate num_traits as traits;
extern crate serde;
use std::cmp::Ordering;
+use std::convert::TryFrom;
use std::default::Default;
use std::error::Error;
use std::fmt;
@@ -390,7 +391,7 @@ imp... | 2 | 26 | 14 |
9761dc6315ad6e48d738bae3d3432702052b939a | Denis Kolodin | 2020-05-28T20:26:37 | Remove deprecated try macros | diff --git a/src/lib.rs b/src/lib.rs
index dff4cee..1f5bdb3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1621,7 +1621,7 @@ impl Num for BigDecimal {
_ => exp,
};
- (base, try!(i64::from_str(exp)))
+ (base, i64::from_str(exp)?)
}
... | 1 | 2 | 2 |
03f56367e27b3f4fcaf70b117bcd6fc49c64593a | Leonardo Yvens | 2020-05-01T13:52:52 | Add `BigDecimal::normalized` | diff --git a/src/lib.rs b/src/lib.rs
index 26af706..dff4cee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -627,6 +627,19 @@ impl BigDecimal {
}
return result.with_prec(100);
}
+
+ pub fn normalize(&self) -> BigDecimal {
+ let (_, mut digits) = self.int_val.to_u32_digits();
+ let mu... | 1 | 35 | 0 |
22b43be0fefb1611b393b0cb5f6b1143a1f993d0 | Andrew Kubera | 2020-04-26T23:50:26 | Version 0.1.2 | diff --git a/Cargo.toml b/Cargo.toml
index dea478c..94bffca 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.1.0"
+version = "0.1.2"
authors = ["Andrew Kubera"]
description = "Arbitrary percision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
17d800a9070c5b9f531cb8493d783240c6a7de03 | Andrew Kubera | 2020-04-26T23:26:35 | Bump num-integer to version 0.1.42 | diff --git a/Cargo.toml b/Cargo.toml
index 5c765dc..dea478c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ license = "MIT/Apache-2.0"
[dependencies]
num-bigint = "0.2"
-num-integer = "0.1.39"
+num-integer = "0.1.42"
num-traits = "0.2"
serde = { version = "1.0", optional = true } | 1 | 1 | 1 |
9974eee1d7d84e066ea0f8b97c846d6c8ae67ec3 | Andrew Kubera | 2020-01-10T04:03:41 | Bump num-integer to 0.1.41 | diff --git a/Cargo.toml b/Cargo.toml
index 3f2edb2..e67b0de 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ license = "MIT/Apache-2.0"
[dependencies]
num-bigint = "0.2"
-num-integer = "0.1.39"
+num-integer = "0.1.41"
num-traits = "0.2"
serde = { version = "1.0", optional = true } | 1 | 1 | 1 |
2c418a7c0eb5a7e77c132a268f187dbf2473b39a | Andrew Kubera | 2020-01-09T21:42:14 | example:repeated_squares: Reduce iterations to 26 | diff --git a/examples/repeated_squares.rs b/examples/repeated_squares.rs
index 0db19f5..d3d72cf 100644
--- a/examples/repeated_squares.rs
+++ b/examples/repeated_squares.rs
@@ -10,7 +10,7 @@ fn main()
// let mut x = BigDecimal::from(1.1);
let mut x = BigDecimal::from_str("1.1").unwrap();
// for iter in 0... | 1 | 1 | 3 |
be909d5c65369cae8d7823aa0315f96931e766fc | Andrew Kubera | 2019-10-11T03:09:49 | Replace try macro with '?' | diff --git a/src/lib.rs b/src/lib.rs
index a7cd34b..eb65e37 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1608,7 +1608,7 @@ impl Num for BigDecimal {
_ => exp,
};
- (base, try!(i64::from_str(exp)))
+ (base, i64::from_str(exp)?)
}
... | 1 | 2 | 2 |
54dd32bf87cdcd3e2b0649931d71aaac40700d20 | Bill Kaguru Wanjohi | 2019-05-23T23:25:44 | correct typo in package description | diff --git a/Cargo.toml b/Cargo.toml
index 3f2edb2..1ff14d1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
name = "bigdecimal"
version = "0.1.0"
authors = ["Andrew Kubera"]
-description = "Arbitrary percision decimal numbers"
+description = "Arbitrary precision decimal numbers"
documentation = "https://do... | 1 | 1 | 1 |
df4baab3043b40685e09877c87208e8faa6fef9c | cboecking | 2019-04-16T22:53:43 | added simple math example | diff --git a/examples/simple-math.rs b/examples/simple-math.rs
new file mode 100644
index 0000000..85fed98
--- /dev/null
+++ b/examples/simple-math.rs
@@ -0,0 +1,49 @@
+extern crate bigdecimal;
+use bigdecimal::*;
+use std::str::FromStr;
+
+fn main() {
+ println!("Hello, Big Decimals!");
+ let input = "0.8";
+ ... | 1 | 49 | 0 |
2c185fa112f14a2470fe1b696107a6513da8b2b6 | Andrew Kubera | 2019-04-12T16:59:08 | add test_sum1 | diff --git a/src/lib.rs b/src/lib.rs
index 92d171a..a7cd34b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1957,6 +1957,20 @@ mod bigdecimal_tests {
assert_eq!(expected_sum, sum);
}
+ #[test]
+ fn test_sum1() {
+ let vals = vec![
+ BigDecimal::from_f32(0.1).unwrap(),
+ B... | 1 | 14 | 0 |
54626acbe6e6493c46ae74252d5e592e09b660b3 | Andrew Kubera | 2019-04-12T16:07:26 | Prepare version 0.1.0 | diff --git a/Cargo.toml b/Cargo.toml
index c2d3029..3f2edb2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.0.15"
+version = "0.1.0"
authors = ["Andrew Kubera"]
description = "Arbitrary percision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
97a2abfa39f981216199a601f03a8a9ac0f7000a | Andrew Kubera | 2019-02-09T10:36:54 | Add is_integer method | diff --git a/src/lib.rs b/src/lib.rs
index c0a208b..92d171a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -581,6 +581,18 @@ impl BigDecimal {
return result;
}
+ /// Return true if this number has zero fractional part (is equal
+ /// to an integer)
+ ///
+ #[inline]
+ pub fn is_integer(&self... | 1 | 43 | 0 |
11353df3697e1a6f2ecd14ee8850282d4255b501 | Andrew Kubera | 2019-02-09T01:24:49 | Prepare version 0.0.15 | diff --git a/Cargo.toml b/Cargo.toml
index b3b8f36..c2d3029 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bigdecimal"
-version = "0.0.14"
+version = "0.0.15"
authors = ["Andrew Kubera"]
description = "Arbitrary percision decimal numbers"
documentation = "https://docs.rs/bigdecimal" | 1 | 1 | 1 |
747f17961366691e59c8453e525581e97be9a46d | Andrew Kubera | 2019-02-09T01:22:09 | Ignore deprecation warning | diff --git a/src/lib.rs b/src/lib.rs
index e954542..a68a1ba 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -672,6 +672,7 @@ impl FromStr for BigDecimal {
}
}
+#[allow(deprecated)] // trim_right_match -> trim_end_match
impl Hash for BigDecimal {
fn hash<H: Hasher>(&self, state: &mut H) {
let mut dec... | 1 | 1 | 0 |
01fa5faad8dee89689f133cf4f9177b8742f5812 | Andrew Kubera | 2019-02-09T01:03:39 | Add implementation of From<BigInt> | diff --git a/src/lib.rs b/src/lib.rs
index 8c8b3da..e954542 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1668,6 +1668,16 @@ impl From<(BigInt, i64)> for BigDecimal {
}
}
+impl From<BigInt> for BigDecimal {
+ #[inline]
+ fn from(int_val: BigInt) -> Self {
+ BigDecimal {
+ int_val: int_val... | 1 | 10 | 0 |
8a707026bade33abbffdc2f957a13a8e2df0737d | Denis Kolodin | 2019-02-08T11:13:50 | Add string-only feature to force the use of strings
Some serialization formats like `bincode` don't support
`deserialize_any` method. Since `bigdecimal` crate serializes values
to strings only this improvement force to use strings for deserialization
by activating `string-only` feature. | diff --git a/Cargo.toml b/Cargo.toml
index b3b8f36..44b6e82 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,3 +17,6 @@ serde = { version = "1.0", optional = true }
[dev-dependencies.serde_json]
version = "1.0"
+
+[features]
+string-only = []
diff --git a/src/lib.rs b/src/lib.rs
index c054fe1..3a78622 100644
--- a/s... | 2 | 16 | 0 |
b645ba254b475ffb2687191b1ac9c079737c7718 | Greg | 2018-11-03T05:18:29 | Remove unnecessary added line | diff --git a/src/lib.rs b/src/lib.rs
index 619883a..c054fe1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -714,7 +714,6 @@ impl One for BigDecimal {
}
}
-
impl Add<BigDecimal> for BigDecimal {
type Output = BigDecimal; | 1 | 0 | 1 |
ba94bbd35b20cab7c4053998a86a3f86a5494c8e | Greg | 2018-11-03T05:17:13 | Implement std::iter::Sum | diff --git a/src/lib.rs b/src/lib.rs
index eba4e73..619883a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -53,6 +53,7 @@ use std::fmt;
use std::hash::{Hash, Hasher};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
+use std::iter::Sum;
use ... | 1 | 30 | 0 |
c5a7622c29ef0fe2bda7dd68d7bdc16a3fe3f46e | Andrew Kubera | 2018-09-03T23:25:28 | Fix subtle `with_prec` bug | diff --git a/src/lib.rs b/src/lib.rs
index d40d073..8c8b3da 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -219,10 +219,13 @@ impl BigDecimal {
if digits > prec {
let diff = digits - prec;
+ let p = ten_to_the(diff);
+ let (mut q, r) = self.int_val.div_rem(&p);
- ... | 1 | 11 | 3 |
823b8fe77c3a282abb9bb3f7c314707512d0de12 | Andrew Kubera | 2018-08-22T15:32:39 | Make division-by-zero a panicable offence | diff --git a/src/lib.rs b/src/lib.rs
index 9ab8e47..d40d073 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1269,7 +1269,7 @@ impl Div<BigDecimal> for BigDecimal {
#[inline]
fn div(self, other: BigDecimal) -> BigDecimal {
if other.is_zero() {
- return other;
+ panic!("Division by z... | 1 | 18 | 3 |
8fda712a17ef28635ac6bba895cdbabed59a91c3 | Andrew Kubera | 2018-08-08T00:26:32 | Add inverse() method | diff --git a/src/lib.rs b/src/lib.rs
index d635444..9ab8e47 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -516,7 +516,68 @@ impl BigDecimal {
return result;
}
- /// Evaluate the natural-exponential function $e^x$
+ /// Compute the reciprical of the number: x<sup>-1</sup>
+ #[inline]
+ pub fn i... | 1 | 82 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.