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
7d800267d14be8959c0f7f64fc7509d0b01c7582
Andrew Kubera
2018-08-03T00:35:41
Implementations of some {Add,Sub,Mul}{,Assign}<BigInt>
diff --git a/src/lib.rs b/src/lib.rs index eba4e73..d635444 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,9 +79,9 @@ fn ten_to_the(pow: u64) -> BigInt { x } else { x * ten_to_the(rem) + } } } -} #[inline(always)] fn count_decimal_digits(int: &BigInt) -> u64 { @@ -53...
2
241
27
cb320671d3793c294d89622251a141b90e334750
Andrew Kubera
2018-07-26T03:09:15
Add repeated_squares example
diff --git a/examples/repeated_squares.rs b/examples/repeated_squares.rs new file mode 100644 index 0000000..0db19f5 --- /dev/null +++ b/examples/repeated_squares.rs @@ -0,0 +1,23 @@ + +extern crate bigdecimal; + +use bigdecimal::BigDecimal; +use std::time::Instant; +use std::str::FromStr; + +fn main() +{ + // let m...
1
23
0
d04275b2ce49698587f5dea960bff6d4b6ec81a3
Andrew Kubera
2018-07-27T07:29:23
Prepare version 0.0.14
diff --git a/Cargo.toml b/Cargo.toml index 954df4f..b3b8f36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bigdecimal" -version = "0.0.13" +version = "0.0.14" authors = ["Andrew Kubera"] description = "Arbitrary percision decimal numbers" documentation = "https://docs.rs/bigdecimal"
1
1
1
f2ae3563b544245988f504a586ff505ce6b151d9
Andrew Kubera
2018-07-27T06:19:20
Fix num-bigint dependency to minor level
diff --git a/Cargo.toml b/Cargo.toml index 89e721d..954df4f 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.2.0" +num-bigint = "0.2" num-integer = "0.1.39" num-tra...
1
1
1
5b92d6648ac62f3c259db87ea656f069bb1f05d7
Andrew Kubera
2018-07-27T06:15:43
Fix unhandled division of zero bug
diff --git a/src/lib.rs b/src/lib.rs index f0716e5..eba4e73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -927,6 +927,11 @@ impl_div_for_primitives!(); #[inline(always)] fn impl_division(mut num: BigInt, den: &BigInt, mut scale: i64, max_precision: u64) -> BigDecimal { + // quick zero check + if num.is_zero() {...
1
10
3
7b2e71a761849dcaba560fb8d5a8fd41e6eb17e1
Andrew Kubera
2018-07-27T06:46:02
Add implementation of `exp()` method
diff --git a/src/lib.rs b/src/lib.rs index 995cb23..f0716e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -515,6 +515,36 @@ impl BigDecimal { return result; } + + /// Evaluate the natural-exponential function $e^x$ + /// + #[inline] + pub fn exp(&self) -> BigDecimal { + if self.is_zero(...
1
53
0
f4fed25ded59caa5e787a9b3167b7a6ce411094c
Andrew Kubera
2018-07-26T02:19:18
Apply rustfmt to source
diff --git a/src/lib.rs b/src/lib.rs index 8ea22ee..995cb23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,29 +40,28 @@ //! println!("Input ({}) with 10 decimals: {} vs {})", input, dec, float); //! ``` -extern crate num_integer; extern crate num_bigint; +extern crate num_integer; extern crate num_traits as trai...
2
92
105
d16c61e5ece2a3977c453480460218827a09b6e6
Andrew Kubera
2018-07-26T02:17:16
Add new test conditions for each borrow-state mathematics trait
diff --git a/src/lib.rs b/src/lib.rs index ba937a6..8ea22ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1717,8 +1717,11 @@ mod bigdecimal_tests { let b = BigDecimal::from_str(y).unwrap(); let c = BigDecimal::from_str(z).unwrap(); - let s = a.clone() + b.clone(); - asse...
1
22
8
561d9093dbcb59a72fee0312c0f506ea04ae8cb3
Andrew Kubera
2018-07-26T02:01:59
Add explicit implementation of Sub for the various ownership conditions
diff --git a/src/lib.rs b/src/lib.rs index 3e3ae74..ba937a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -754,7 +754,52 @@ impl<'a> AddAssign<&'a BigDecimal> for BigDecimal { } } -forward_all_binop_to_ref_ref!(impl Sub for BigDecimal, sub); +impl Sub<BigDecimal> for BigDecimal { + type Output = BigDecimal; + ...
1
52
9
0e165ee942335cb775368af76017f12c840e3f66
Andrew Kubera
2018-07-26T02:01:34
Cleanup Add methods using recursion
diff --git a/src/lib.rs b/src/lib.rs index cfa8bce..3e3ae74 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -679,24 +679,16 @@ impl Add<BigDecimal> for BigDecimal { #[inline] fn add(self, rhs: BigDecimal) -> BigDecimal { let mut lhs = self; - let mut rhs = rhs; match lhs.scale.cmp(&rhs....
1
20
38
671cb08825e6ee0ede5f3a3567acebde0f66b41d
Andrew Kubera
2018-07-23T22:45:48
Add explicit implementation of Mul for the various ownership conditions
diff --git a/src/lib.rs b/src/lib.rs index 174a66a..cfa8bce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -813,7 +813,36 @@ impl<'a> SubAssign<&'a BigDecimal> for BigDecimal { } } -forward_all_binop_to_ref_ref!(impl Mul for BigDecimal, mul); +impl Mul<BigDecimal> for BigDecimal { + type Output = BigDecimal; + ...
1
30
1
2887e61c29f12e0bb5f49e1294f52ec36798b147
Andrew Kubera
2018-07-23T22:40:36
Add explicit implementation of Add for the various ownership conditions
diff --git a/src/lib.rs b/src/lib.rs index e6de83c..174a66a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -672,7 +672,66 @@ impl One for BigDecimal { } } -forward_all_binop_to_ref_ref!(impl Add for BigDecimal, add); + +impl Add<BigDecimal> for BigDecimal { + type Output = BigDecimal; + + #[inline] + fn a...
1
69
12
4a7fd4ddcc46647c3db82f5572d10a23835231c0
Andrew Kubera
2018-07-23T20:57:21
Fix potential infinite loop in sqrt & cbrt
diff --git a/src/lib.rs b/src/lib.rs index 59c405a..e6de83c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -407,8 +407,16 @@ impl BigDecimal { // TODO: Use context variable to set precision let max_precision = 100; - // result has increasing precision - let mut running_result = (self / &g...
1
27
7
0d0e5ffa85ec482f2a28232e20553d51bc1858ab
Andrew Kubera
2018-07-16T22:36:13
Implement `cbrt()` method and add tests
diff --git a/src/lib.rs b/src/lib.rs index 38846ff..59c405a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -432,6 +432,63 @@ impl BigDecimal { return Some(result); } + + /// Take the cube root of the number + /// + #[inline] + pub fn cbrt(&self) -> BigDecimal { + if self.is_zero() || sel...
1
74
0
c5a4a69689a36547380020614974a3b81d8f95c0
Andrew Kubera
2018-07-23T16:31:11
test_div: Add tests using negative operands
diff --git a/src/lib.rs b/src/lib.rs index b238605..38846ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1610,10 +1610,10 @@ mod bigdecimal_tests { ("5", "4", "125e-2"), ("100", "5", "20"), ("-50", "5", "-10"), - ("200", "5", "40."), + ("200", "-5", "-40."), ...
1
3
3
1f03c729bb35e2b1186b010fc1efca9dcf81abb4
Andrew Kubera
2018-07-21T14:58:52
Implement division traits for primitive types
diff --git a/src/lib.rs b/src/lib.rs index fd53b19..b238605 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -706,8 +706,7 @@ impl<'a> MulAssign<&'a BigDecimal> for BigDecimal { } -impl_div_for_integers!(i8); -impl_div_for_integers!(u8); +impl_div_for_primitives!(); #[inline(always)] diff --git a/src/macros.rs b/s...
2
183
5
dc62d5575488a64db715d678e2041b50c2b40b8f
Andrew Kubera
2018-07-23T05:43:22
sqrt: Refactor again and add more tests
diff --git a/src/lib.rs b/src/lib.rs index c132013..fd53b19 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -389,43 +389,48 @@ impl BigDecimal { let log2_10 = 3.32192809488736234787031942948939018_f64; let magic_guess_scale = 1.1951678538495576_f64; let initial_guess = (self.int_val.b...
1
33
27
9fa121db3d39cd9ba9a8de82a39766b413156fe3
Andrew Kubera
2018-07-20T19:07:22
Improve sqrt initial-guess formula
diff --git a/src/lib.rs b/src/lib.rs index ae5d31f..c132013 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -385,8 +385,13 @@ impl BigDecimal { } // make guess - let guess = (self.int_val.bits() as f32 - self.scale as f32 * 3.321928094887362) / 2.0; - let mut result = BigDecimal::from(gues...
1
26
2
abc3dc5ede5b6691701a3a521e8b1fce9e41b9d2
Andrew Kubera
2018-07-19T21:41:34
Add explicit implementation of Div for the various ownership conditions
diff --git a/src/lib.rs b/src/lib.rs index 296f4d0..ae5d31f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -700,110 +700,148 @@ impl_div_for_integers!(i8); impl_div_for_integers!(u8); -forward_all_binop_to_ref_ref!(impl Div for BigDecimal, div); -impl<'a, 'b> Div<&'b BigDecimal> for &'a BigDecimal { - type Output ...
1
108
70
8b26952a41e152640d0d96456b2576a052caad01
Andrew Kubera
2018-07-19T19:12:33
Add explicit implementation of Rem for all 4 ownership permutations
diff --git a/src/lib.rs b/src/lib.rs index 7e7971e..296f4d0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -807,36 +807,80 @@ impl<'a, 'b> Div<&'b BigDecimal> for &'a BigDecimal { } } -forward_all_binop_to_ref_ref!(impl Rem for BigDecimal, rem); +impl Rem<BigDecimal> for BigDecimal { + type Output = BigDecimal;...
1
76
22
19842a7854b8b934bbcd6b1276508c7b0587083f
Andrew Kubera
2018-07-19T19:08:22
Add private inplace rescaling method: `take_and_scale()`
diff --git a/src/lib.rs b/src/lib.rs index 4d5202e..7e7971e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,6 +193,25 @@ impl BigDecimal { } } + #[inline(always)] + fn take_and_scale(mut self, new_scale: i64) -> BigDecimal { + + // let foo = bar.moved_and_scaled_to() + if self.int_v...
1
19
0
0918e886171103ecc28e417d556235a35136ba89
Andrew Kubera
2018-07-19T14:46:43
Add test for get_rounding_term
diff --git a/src/lib.rs b/src/lib.rs index 848bfde..4d5202e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1718,6 +1718,36 @@ mod bigdecimal_tests { } } + #[test] + fn test_get_rounding_term() { + use num_bigint::BigInt; + use super::get_rounding_term; + let vals = vec![ + ...
1
32
0
563d638fac58d458376c5ece9538ee0b5de9cdc2
Andrew Kubera
2018-07-19T14:45:46
Reimplement count_decimal_digits & get_rounding_term to only use loop method
diff --git a/src/lib.rs b/src/lib.rs index 98cac02..848bfde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ pub use traits::{Num, Zero, One, FromPrimitive, ToPrimitive, Signed}; mod macros; -#[inline] +#[inline(always)] fn ten_to_the(pow: u64) -> BigInt { if pow < 20 { BigInt::from(10u64....
1
33
154
f7884f1d6e901874fb9088d85b08bf816c6d8043
Andrew Kubera
2018-07-19T14:10:36
Move macros into separate "macros" module
diff --git a/src/lib.rs b/src/lib.rs index 003f562..98cac02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,57 +59,8 @@ use num_integer::Integer; use num_bigint::{BigInt, ParseBigIntError, Sign, ToBigInt}; pub use traits::{Num, Zero, One, FromPrimitive, ToPrimitive, Signed}; -macro_rules! forward_val_val_binop { - ...
2
83
79
05c9d7da65d66c3eed92b3f7a331408225c042ee
Andrew Kubera
2018-07-19T11:56:01
Add missing commas to support v1.16
diff --git a/src/lib.rs b/src/lib.rs index 7f02210..003f562 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,7 +184,7 @@ fn count_decimal_digits(int: &BigInt) -> u64 152 => match x[1] { 0 ... 149 => 7, 150 => match x[0] { 0 ... 127 => 7, _ => 8, }, // 10000000 - ...
1
6
6
24f4f2dfc50d20a12aed63b5b4e764baa002c32f
Andrew Kubera
2018-07-19T00:32:35
Remove `break <value>;` feature to support rust v1.16
diff --git a/src/lib.rs b/src/lib.rs index aa26afb..7f02210 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -297,11 +297,11 @@ fn get_rounding_term(num: &BigInt) -> u8 { let mut n = BigInt::from(50000000); loop { if num < &n { - break 0; + ret...
1
3
3
51f3aa53e18fe479cf520b5276a2c22aa17d42b9
Andrew Kubera
2018-07-18T17:45:59
Reimplement div method
diff --git a/src/lib.rs b/src/lib.rs index 902c007..aa26afb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -859,7 +859,6 @@ impl<'a> MulAssign<&'a BigDecimal> for BigDecimal { } } -forward_all_binop_to_ref_ref!(impl Div for BigDecimal, div); macro_rules! impl_div_for_integers { // (impl $imp:ident for $res...
1
93
36
dc27105d89229c37c3d1a4af4bd22e6f5714027a
Andrew Kubera
2018-07-16T22:36:13
Add cube() method
diff --git a/src/lib.rs b/src/lib.rs index ffbdc8d..902c007 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -522,6 +522,18 @@ impl BigDecimal { } } } + + #[inline] + pub fn cube(&self) -> BigDecimal { + if self.is_zero() || self.is_one() { + self.clone() + } els...
1
35
0
15c935a6d24cc9470f17978efc54f03f664b388a
Andrew Kubera
2018-07-18T17:47:41
Add test-cases to test_sqrt
diff --git a/src/lib.rs b/src/lib.rs index c41ed40..ffbdc8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1919,6 +1919,8 @@ mod bigdecimal_tests { ("100", "10"), ("49", "7"), (".25", ".5"), + ("0.0152399025", ".12345"), + ("152399025", "12345"), (...
1
2
0
fc01dadc093fbdd9a396dd54f30286b9afee9644
Andrew Kubera
2018-07-16T22:37:14
Make test_half() check result precision
diff --git a/src/lib.rs b/src/lib.rs index 8d2be8c..c41ed40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1894,18 +1894,20 @@ mod bigdecimal_tests { #[test] fn test_half() { let vals = vec![ - ("100", "50"), + ("100", "50."), ("2", "1"), (".2", ".1"), ...
1
3
1
bb2dad0714489ec073d4d807cb454265ff2a7fb7
Andrew Kubera
2018-07-18T17:48:33
Add test for count_decimal_digits
diff --git a/src/lib.rs b/src/lib.rs index 9852791..8d2be8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1860,6 +1860,37 @@ mod bigdecimal_tests { } } + #[test] + fn test_count_decimal_digits() { + use num_bigint::BigInt; + use super::count_decimal_digits; + let vals = vec![ +...
1
31
0
6703be78ae09e75dd7bbf3cbb9f25a2a0bb2a6da
Andrew Kubera
2018-07-18T17:40:41
Implement count_decimal_digits function
diff --git a/src/lib.rs b/src/lib.rs index aabf706..9852791 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,6 +142,66 @@ macro_rules! forward_val_assignop { } +fn count_decimal_digits(int: &BigInt) -> u64 +{ + // let mut result: u64 = 1; + // let mut boundary = BigInt::from(10); + // while &boundary <= i...
1
61
7
13be37d8abd07d51a335b52458a495c7c64b3a6a
Andrew Kubera
2018-07-16T22:34:44
Implement square() method
diff --git a/src/lib.rs b/src/lib.rs index 269edbd..aabf706 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -456,6 +456,19 @@ impl BigDecimal { } } + /// + #[inline] + pub fn square(&self) -> BigDecimal { + if self.is_zero() || self.is_one() { + self.clone() + } else { + ...
1
35
0
15bc5e939b42666c8584259177dc242dcdc286f9
Andrew Kubera
2018-07-16T22:34:26
Implement double() method
diff --git a/src/lib.rs b/src/lib.rs index 051ebc5..269edbd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -420,6 +420,18 @@ impl BigDecimal { } } + #[inline] + pub fn double(&self) -> BigDecimal { + if self.is_zero() { + self.clone() + } else { + BigDecimal { + ...
1
31
0
37a80cdcc5ede6b25e0346b83150df61df3c663a
Andrew Kubera
2018-07-16T16:47:28
Implement `sqrt()` method using Babylonian method
diff --git a/src/lib.rs b/src/lib.rs index 6ee3a81..051ebc5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -441,7 +441,59 @@ impl BigDecimal { int_val: self.int_val.clone().mul(5u8), scale: self.scale + 1, } -} + } + } + + /// Take the square root of the number +...
1
75
1
acee5bf031e9c563dcef4e0a6c07be19b8c9fcab
Andrew Kubera
2018-07-16T16:45:03
Implement `with_prec()` method, create new BigDecimal with specified precision
diff --git a/src/lib.rs b/src/lib.rs index 7fb07d9..6ee3a81 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,6 +316,36 @@ impl BigDecimal { } } + /// Return a new BigDecimal object with precision set to new value + /// + #[inline] + pub fn with_prec(&self, prec: u64) -> BigDecimal { + ...
1
46
0
0e7665b90f6331728542ced5eda96c84e9b5df23
Andrew Kubera
2018-07-16T16:44:17
Fix bug in `div()`: Was incorrect if denominator large, last-digit now rounded
diff --git a/src/lib.rs b/src/lib.rs index 7947c3e..7fb07d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -688,13 +688,35 @@ impl<'a> MulAssign<&'a BigDecimal> for BigDecimal { forward_all_binop_to_ref_ref!(impl Div for BigDecimal, div); +macro_rules! impl_div_for_integers { + // (impl $imp:ident for $res:ty, $me...
1
50
3
783f93263950c2de25f3a438bdd09b0649b22760
Andrew Kubera
2018-07-16T16:38:22
Implement `get_rounding_term()` function, used for testing left-most-digit
diff --git a/src/lib.rs b/src/lib.rs index bea4ca4..7947c3e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,6 +141,119 @@ macro_rules! forward_val_assignop { } } + +/// Internal function used for rounding +/// +/// returns 1 if most significant digit is >= 5, otherwise 0 +/// +/// This is used after dividing a...
1
113
0
c119d53dc8e3294021acf8f8b4e36bcf4178d51c
Andrew Kubera
2018-07-16T16:36:44
Implement `digits()` method - naive procedure counting all digits
diff --git a/src/lib.rs b/src/lib.rs index 2275b6f..bea4ca4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -255,6 +255,19 @@ impl BigDecimal { (self.int_val, self.scale) } + /// Number of digits in the non-scaled integer representation + /// + #[inline] + pub fn digits(&self) -> u64 { + ...
1
27
0
cbaa2c0f778e1800922e5b33325309b1bc1abfb2
Andrew Kubera
2018-07-15T02:55:13
Implement `half()` method
diff --git a/src/lib.rs b/src/lib.rs index d047f01..2275b6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -263,6 +263,30 @@ impl BigDecimal { scale: self.scale, } } + + /// Divide this efficiently by 2 + /// + /// Note, if this is odd, the precision will increase by 1, regardless + ...
1
42
0
5e60029bc13394150f97aebeb0923658477c9f1a
Andrew Kubera
2018-07-15T02:47:44
Skip rustfmt on _test submodule
diff --git a/src/lib.rs b/src/lib.rs index 3d26f1e..d047f01 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1038,7 +1038,6 @@ mod bigdecimal_serde { } } - #[cfg_attr(rustfmt, rustfmt_skip)] #[test] fn test_serde_deserialize_int() { use traits::FromPrimitive; @@ -1085,6 +1084,7 @@ mod ...
1
1
5
0cc655be41ccf59e5106c364508ada93d12473de
Andrew Kubera
2018-06-26T22:34:13
Implement custom Debug formatting
diff --git a/src/lib.rs b/src/lib.rs index 0ef2241..3d26f1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -143,7 +143,7 @@ macro_rules! forward_val_assignop { /// A big decimal type. /// -#[derive(Clone, Debug, Eq)] +#[derive(Clone, Eq)] pub struct BigDecimal { int_val: BigInt, // A positive scale means a ...
1
23
1
289e690f5b9dc4d924388fb846501c562f61c5e2
StevenDoesStuffs
2018-06-26T17:07:48
Fix doctests
diff --git a/src/lib.rs b/src/lib.rs index 8344a61..f4e3e87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -208,13 +208,13 @@ impl BigDecimal { /// # Examples /// /// ``` - /// extern crate num; + /// extern crate num_bigint; /// extern crate bigdecimal; /// use std::str::FromStr; /// -...
1
8
8
f9759e02efc1ae56d6913a2a9eba4393d731f444
StevenDoesStuffs
2018-06-26T16:56:28
Update lib.rs
diff --git a/src/lib.rs b/src/lib.rs index 87e12f7..8344a61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,13 +40,12 @@ //! println!("Input ({}) with 10 decimals: {} vs {})", input, dec, float); //! ``` -extern crate num; +extern crate num_integer; +extern crate num_bigint; extern crate num_traits as traits; #[c...
1
27
28
480168f81fa589b167b907c23ac7c87e5da7af85
StevenDoesStuffs
2018-06-26T16:56:02
Update dependencies
diff --git a/Cargo.toml b/Cargo.toml index 014baae..40836e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ keywords = ["mathematics", "numerics", "decimal", "arbitrary-precision", "floati license = "MIT/Apache-2.0" [dependencies] -num = { version = "0.1.42", default-features=false, features=["bigint"] }...
1
2
1
c4d38f18a3ca632f3447cab3f909a6208f89a7a3
Kevin Stenerson
2018-05-31T19:11:24
Update serde implementation to fix tests for serde_json:1.0.8 and above. See the release notes for https://github.com/serde-rs/json/releases/tag/v1.0.8 explaining the break in compatibility.
diff --git a/Cargo.toml b/Cargo.toml index 014baae..2fe554f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT/Apache-2.0" [dependencies] num = { version = "0.1.42", default-features=false, features=["bigint"] } num-traits = "0.2" -serde = { version = "1", optional = true } +serde = { version ...
2
3
3
27a689df03c237ab6e3623b7f79ad923c551569e
Aidan Hobson Sayers
2018-05-26T23:33:12
Add rem implementation
diff --git a/src/lib.rs b/src/lib.rs index 210e655..af67f95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,6 +147,7 @@ macro_rules! forward_val_assignop { #[derive(Clone, Debug, Eq)] pub struct BigDecimal { int_val: BigInt, + // A positive scale means a negative power of 10 scale: i64, } @@ -180,8 +...
1
70
8
cdb05cfb42998b07bca7cc3ff3263daa5c2fb212
Nikola Ilo
2018-05-24T01:20:52
use fmt::Formatter::pad_integral to implement number style width/padding
diff --git a/src/lib.rs b/src/lib.rs index 210e655..07fb8bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -684,26 +684,18 @@ impl fmt::Display for BigDecimal { }; // Concatenate everything - let complete = if !after.is_empty() { + let complete_without_sign = if !after.is_empty() { ...
1
18
23
1c97b0901a8bb2f354051831ab1f3f2c4559d05d
Andrew Kubera
2018-02-09T08:13:44
Dependency version bump (num 0.1.40 🠦 0.1.42)
diff --git a/Cargo.toml b/Cargo.toml index b06ca32..6760f9c 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 = { version = "0.1.40", default-features=false, features=["bigint"] }...
1
1
1
19710edbedab06db9c96b2e8a347c9fb4283fa6f
Bastien Orivel
2018-03-16T19:37:58
Update num-traits and bump version
diff --git a/Cargo.toml b/Cargo.toml index a01b1be..b06ca32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bigdecimal" -version = "0.0.10" +version = "0.0.11" authors = ["Andrew Kubera"] description = "Arbitrary percision decimal numbers" documentation = "https://docs.rs/bigdecimal" @@ ...
1
2
2
d5da9e4c39c499a2b2c63b6e78471cdb8953f102
Luca Bruno
2018-02-08T11:38:40
clippy: fix few idiomatic warnings
diff --git a/src/lib.rs b/src/lib.rs index 8837178..210e655 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,17 +193,14 @@ impl BigDecimal { if new_scale > self.scale { let scale_diff = new_scale - self.scale; let int_val = &self.int_val * ten_to_the(scale_diff as u64); - r...
1
14
25
33c4cb54b66f193d788871989a5f99fae1eeec2f
Luca Bruno
2018-02-08T11:26:53
examples: add a floating-point precision example
diff --git a/examples/floating-precision.rs b/examples/floating-precision.rs new file mode 100644 index 0000000..2813a1e --- /dev/null +++ b/examples/floating-precision.rs @@ -0,0 +1,14 @@ +extern crate bigdecimal; + +use bigdecimal::BigDecimal; +use std::str::FromStr; + +fn main() { + let input = std::env::args().s...
1
14
0
52688c4694a220a718cac014531d1291a59f75c4
Luca Bruno
2018-02-08T11:24:51
doc: fix CommonMark syntax and add example
diff --git a/src/lib.rs b/src/lib.rs index aa869b5..8837178 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,14 +12,14 @@ //! A Big Decimal //! -//! BigDecimal allows storing any real number to arbitrary precision; which +//! `BigDecimal` allows storing any real number to arbitrary precision; which //! avoids commo...
1
15
3
2ee10905bb2e24155a2fe21bcbcd664a34cc9e2c
Luca Bruno
2018-02-08T11:18:02
cargo: remove unused dev-depencency
diff --git a/Cargo.toml b/Cargo.toml index e7274f6..a01b1be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,5 @@ num = { version = "0.1.40", default-features=false, features=["bigint"] } num-traits = "0.1.40" serde = { version = "1", optional = true } -[dev-dependencies.rand] -version = "0.3" - [dev-dependen...
1
0
3
8f32aa163d96f2b56dbbe507763d92ed1e306cd8
Andrew Kubera
2017-10-07T02:30:12
abs: Implemented trivial absolute-value method with test
diff --git a/src/lib.rs b/src/lib.rs index 4fd1bf9..aa869b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,6 +243,15 @@ impl BigDecimal { pub fn into_bigint_and_exponent(self) -> (BigInt, i64) { (self.int_val, self.scale) } + + /// Compute the absolute value of number + #[inline] + pub fn ...
1
23
0
4acff7b5f4970b66264bd103fc907c26e8436b70
Andrew Kubera
2017-08-13T06:47:02
Dependency version bump num : 0.1.39 -> 0.1.40
diff --git a/Cargo.toml b/Cargo.toml index 65939b8..e7274f6 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 = { version = "0.1.37", default-features=false, features=["bigint"] }...
1
2
2
532b03dad1d86bab4933b5cb81c9de58b4df82f6
Andrew Kubera
2017-08-26T06:10:30
Removed unused macro to quiet compile warnings
diff --git a/src/lib.rs b/src/lib.rs index a22bd6a..4fd1bf9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,19 +90,6 @@ macro_rules! forward_val_ref_binop { } } -macro_rules! forward_ref_ref_binop { - (impl $imp:ident for $res:ty, $method:ident) => { - impl<'a, 'b> $imp<&'b $res> for &'a $res { - ...
1
0
13
a8c3081acfe335d7adc1465c139cacb8c5fb5e26
Andrew Kubera
2017-08-26T06:09:13
Reorganized imports and now publicly using the num-traits Traits
diff --git a/src/lib.rs b/src/lib.rs index f88d242..a22bd6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,16 +36,17 @@ extern crate serde; use num::{bigint, integer}; use std::fmt; -use integer::Integer; use std::error::Error; +use std::cmp::Ordering; use std::default::Default; use std::str::{self, FromStr}; -...
1
10
7
b292b52e39c3407982656265807090bca304b9e0
Niclas Hoyer
2017-10-19T16:23:07
Add more test cases to hash equality and fix edge cases
diff --git a/src/lib.rs b/src/lib.rs index f740cf5..f20dffd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -314,7 +314,20 @@ impl FromStr for BigDecimal { impl Hash for BigDecimal { fn hash<H: Hasher>(&self, state: &mut H) { - self.int_val.to_str_radix(10).trim_right_matches('0').hash(state); + let m...
1
76
2
a3f9512984a1217f8ca3de1c33794f0610b59549
Niclas Hoyer
2017-10-19T13:30:45
Fix hash value for decimals considered equal Fixes #23
diff --git a/src/lib.rs b/src/lib.rs index 40d1065..f740cf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,7 @@ use std::ops::{Add, Div, Mul, Rem, Sub, AddAssign, MulAssign, SubAssign, Neg}; use traits::{Num, Zero, One, FromPrimitive, ToPrimitive, Signed}; use std::num::{ParseFloatError, ParseIntError}; use s...
1
39
1
4bad73d3b720fdada37d06ff9bcc718c95426570
Andrew Kubera
2017-08-02T14:02:43
Fixed improper keyword in Cargo.toml
diff --git a/Cargo.toml b/Cargo.toml index 93e66f5..65939b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ description = "Arbitrary percision decimal numbers" documentation = "https://docs.rs/bigdecimal" homepage = "https://github.com/akubera/bigdecimal-rs" repository = "https://github.com/akubera/bigdecim...
1
1
1
e45ac48f82dd99aa45a4cd55eebdc0b1f620da69
Andrew Kubera
2017-08-02T13:43:50
BigDecimal - v0.0.10 (arbitrary version bump) This adds support for serialization with serde (v1.0) and removes legay rustc_serialize. Added 'as_bigint_and_exponent' & 'into_bigint_and_exponent' methods. Implemented From<> traits for many primitive numeric types.
diff --git a/Cargo.toml b/Cargo.toml index 786d613..93e66f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bigdecimal" -version = "0.0.7" +version = "0.0.10" authors = ["Andrew Kubera"] description = "Arbitrary percision decimal numbers" documentation = "https://docs.rs/bigdecimal"
1
1
1
598d37c5ac52fd5a01ec98228ee2b2608aceaabc
Kevin Stenerson
2017-07-16T18:41:10
Update Serialize/Deserialize to Serde 1.0
diff --git a/Cargo.toml b/Cargo.toml index 751c446..786d613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ license = "MIT/Apache-2.0" [dependencies] num = { version = "0.1.37", default-features=false, features=["bigint"] } num-traits = "0.1.37" -serde = { version = "0.9", optional = true } +serde = { v...
2
7
7
8e0f185ec54400dd3a1d5580597e725b9a5b8555
Kevin Stenerson
2017-07-16T18:36:47
Implement Serialize/Deserialzie w/ feature flag
diff --git a/Cargo.toml b/Cargo.toml index 039b0f3..751c446 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,10 @@ license = "MIT/Apache-2.0" [dependencies] num = { version = "0.1.37", default-features=false, features=["bigint"] } num-traits = "0.1.37" +serde = { version = "0.9", optional = true } [dev-depen...
2
166
0
847bab223bdd2171e5255fffdd8db10744666084
Andrew Kubera
2017-05-15T19:15:35
Removed serialization attributes
diff --git a/src/lib.rs b/src/lib.rs index d6359f3..8f15745 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,11 +28,6 @@ //! directly, as the floating point representation may be unexpected. //! -#[cfg(feature = "rustc-serialize")] -extern crate rustc_serialize; -#[cfg(feature = "serde")] -extern crate serde; - ext...
1
0
6
92d85d2ab990ed6d4b8c965239b4aec0be29a1a5
Andrew Kubera
2017-04-10T16:28:20
Added additional keywords to crate metadata
diff --git a/Cargo.toml b/Cargo.toml index 29c1466..039b0f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ description = "Arbitrary percision decimal numbers" documentation = "https://docs.rs/bigdecimal" homepage = "https://github.com/akubera/bigdecimal-rs" repository = "https://github.com/akubera/bigdecim...
1
1
1
f5e9a3280eb7150b657ed608a9bd38fb805eb6e6
Yurii Rashkovskii
2017-05-15T10:23:02
Problem: impossible to get internal representation In certain cases, when custom encoding schemes or algorithms are implemented, it is beneficial to be able to get the internal bigint and associated scale of the BigDecimal. Solution: add as_bigint_and_exponent() and into_bigint_and_exponent() functions. Also, add Fr...
diff --git a/src/lib.rs b/src/lib.rs index c5b91ba..d6359f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -222,6 +222,41 @@ impl BigDecimal { pub fn sign(&self) -> num::bigint::Sign { self.int_val.sign() } + + /// Return the internal big integer value and an exponent + /// + /// # Examples + ...
1
46
0
f7727102cb42c85b87754a7c759d5cb5c1e88b52
Andrew Kubera
2017-05-12T17:59:08
From<f32> & From<f64> now preserves the accuracy and precision of the source number
diff --git a/src/lib.rs b/src/lib.rs index cab0be6..c5b91ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -788,14 +788,14 @@ impl_from_type!(i32, i64); impl From<f32> for BigDecimal { #[inline] fn from(n: f32) -> Self { - BigDecimal::from_str(&format!("{:.16}", n)).unwrap() - } + BigDecimal::...
1
18
11
7247fb2df7e1131944d43ec2093eb4bb7da05d1c
Andrew Kubera
2017-05-12T16:41:15
Implemented From<> for all primitive floats & integers - FromPrimitive rewritten to use these instead
diff --git a/src/lib.rs b/src/lib.rs index bc1ba59..cab0be6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -746,38 +746,86 @@ impl ToPrimitive for BigDecimal { } } +impl From<i64> for BigDecimal { + #[inline] + fn from(n: i64) -> Self { + BigDecimal { + int_val: BigInt::from(n), + ...
1
62
14
be62df85cb4b36175982066e2450d8c223ad8d79
Andrew Kubera
2017-05-12T15:52:20
Cleaned implementation of fmt::Display for ParseBigDecimalError
diff --git a/src/lib.rs b/src/lib.rs index 11f52b8..bc1ba59 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -235,12 +235,14 @@ pub enum ParseBigDecimalError { impl fmt::Display for ParseBigDecimalError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - &ParseBigDecimalError:...
1
8
6
e46b64af57bd1d54668de6e7f72d79871710b05d
Andrew Kubera
2017-05-12T15:42:32
Implemented `FromPrimitive` trait + tests
diff --git a/src/lib.rs b/src/lib.rs index 6dbfda0..11f52b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -744,6 +744,38 @@ impl ToPrimitive for BigDecimal { } } +impl FromPrimitive for BigDecimal { + fn from_i64(n: i64) -> Option<Self> + { + BigInt::from_i64(n).map(|int_val| { + BigDecimal...
1
94
1
67d2adec2a6e871178c26a1ddd1ef5bc65738d77
Andrew Kubera
2017-05-02T14:29:52
Version 0.0.7
diff --git a/Cargo.toml b/Cargo.toml index 1333c22..29c1466 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bigdecimal" -version = "0.0.1" +version = "0.0.7" authors = ["Andrew Kubera"] description = "Arbitrary percision decimal numbers" documentation = "https://docs.rs/bigdecimal"
1
1
1
9ace16e74724a8849b2a449b2edd2947dbe63a44
Andrew Kubera
2017-05-02T14:28:56
Updated dependency versions (num: 1.37, rand: 0.3.*)
diff --git a/Cargo.toml b/Cargo.toml index 4ca8079..1333c22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ keywords = ["mathematics", "numerics"] license = "MIT/Apache-2.0" [dependencies] -num = { version = "0.1.35", default-features=false, features=["bigint"] } -num-traits = "0.1.35" +num = { version =...
1
3
3
dc2ffb53c3ee6797a43b1fd0663a93a068384ff7
Ruben De Smet
2017-04-09T18:01:13
Add tests for to_i64
diff --git a/src/lib.rs b/src/lib.rs index 6c1a517..6dbfda0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -757,6 +757,24 @@ mod bigdecimal_tests { use std::str::FromStr; use num; + #[test] + fn test_to_i64() { + let vals = vec![ + ("12.34", 12), + ("3.14", 3), + (...
1
18
0
0399cc1d4727cb9c08781c26b2b8bc633a29856e
Ruben De Smet
2017-04-09T17:58:48
Removes unnecessary and bugged checks.
diff --git a/src/lib.rs b/src/lib.rs index c11e369..6c1a517 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -724,37 +724,17 @@ impl Num for BigDecimal { impl ToPrimitive for BigDecimal { fn to_i64(&self) -> Option<i64> { - // Boundaries of i64: match self.sign() { - Sign::Plus => { - ...
1
4
24
db5c2a05a6623119264b4217a782d4604af988cb
Ruben De Smet
2017-04-08T15:46:59
Add to_f64 in ToPrimitive
diff --git a/src/lib.rs b/src/lib.rs index 26b124c..c11e369 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -756,6 +756,12 @@ impl ToPrimitive for BigDecimal { } None } + + fn to_f64(&self) -> Option<f64> { + self.int_val.to_f64().map(|x| { + x * 10f64.powi(-self.scale as i32) + ...
1
23
0
e42390eb8cb7c5b893a06a926906bee5a63d456f
Ruben De Smet
2017-04-07T17:52:22
Naive ToBigInt conversion
diff --git a/src/lib.rs b/src/lib.rs index d205e7b..26b124c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ use integer::Integer; use std::error::Error; use std::default::Default; use std::str::{self, FromStr}; -use bigint::{BigInt, ParseBigIntError, Sign}; +use bigint::{BigInt, ParseBigIntError, Sign, To...
1
7
1
68622c0cb7814dcd5fb17c691fc7c80cf47ac9bd
Ruben De Smet
2017-04-07T17:39:16
impl ToPrimitive for BigDecimal
diff --git a/src/lib.rs b/src/lib.rs index 8d5c919..d205e7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,7 @@ use std::default::Default; use std::str::{self, FromStr}; use bigint::{BigInt, ParseBigIntError, Sign}; use std::ops::{Add, Div, Mul, Rem, Sub, AddAssign, MulAssign, SubAssign, Neg}; -use traits::{N...
1
37
1
335d0002d2bedeb880169652d2fc6a2c9ff3abb0
Ruben De Smet
2017-04-07T16:59:55
impl Signed for BigDecimal
diff --git a/src/lib.rs b/src/lib.rs index d8d5271..8d5c919 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,7 +44,7 @@ use std::error::Error; use std::default::Default; use std::str::{self, FromStr}; use bigint::{BigInt, ParseBigIntError, Sign}; -use std::ops::{Add, Div, Mul, Rem, Sub, AddAssign, MulAssign, SubAssig...
1
69
1
0be644c7522f486f03738599890d508c2ac64838
Ruben De Smet
2017-04-07T13:40:25
Partial and complete Ordering
diff --git a/src/lib.rs b/src/lib.rs index e6d24d1..d8d5271 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,7 @@ use bigint::{BigInt, ParseBigIntError, Sign}; use std::ops::{Add, Div, Mul, Rem, Sub, AddAssign, MulAssign, SubAssign}; use traits::{Num, Zero, One, FromPrimitive, Signed}; use std::num::{ParseFloat...
1
50
1
fac43f31cebfbf921e23315995b85e8ae3427cf2
Ruben De Smet
2017-04-07T12:57:21
Add BigDecimal::sign
diff --git a/src/lib.rs b/src/lib.rs index cc2bebf..e6d24d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -203,6 +203,24 @@ impl BigDecimal { } } + + /// Return the sign of the `BigDecimal` as `num::bigint::Sign`. + /// + /// # Examples + /// + /// ``` + /// extern crate num; + /// ex...
1
18
0
577eed17687d95049341104e96aa46cc3a44f25c
Ruben De Smet
2017-04-06T12:39:55
Implements Assign ops AddAssign, SubAssign, MulAssign
diff --git a/src/lib.rs b/src/lib.rs index 7a3a108..4385203 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,7 @@ use std::error::Error; use std::default::Default; use std::str::{self, FromStr}; use bigint::{BigInt, ParseBigIntError}; -use std::ops::{Add, Div, Mul, Rem, Sub}; +use std::ops::{Add, Div, Mul, Rem,...
1
80
7
23670efae8f604838f461768a59f521ddc600aac
Ruben De Smet
2017-04-05T20:33:20
A cleaner std::fmt implementation Implements a more robust fmt::Display Add unit tests: - for negative sign - precision - single leading zero
diff --git a/src/lib.rs b/src/lib.rs index 7a3a108..7094bdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,9 +41,9 @@ use integer::Integer; use std::error::Error; use std::default::Default; use std::str::{self, FromStr}; -use bigint::{BigInt, ParseBigIntError}; +use bigint::{BigInt, ParseBigIntError, Sign}; use st...
1
82
24
89a68439d0ada3ae2cafbf8c0f0aca2e8c2f3f62
Andrew Kubera
2017-04-05T23:45:43
Removed redundant information from project description
diff --git a/Cargo.toml b/Cargo.toml index 0b629a5..4ca8079 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "bigdecimal" version = "0.0.1" authors = ["Andrew Kubera"] -description = "An implementation of arbitrary percision decimal numbers" +description = "Arbitrary percision decimal numbers" docume...
1
1
1
e36304c2cb7580843c1a175f48ccdf4850a35e2d
Ruben De Smet
2017-04-05T18:10:45
Very stupid impl. of std::fmt
diff --git a/src/lib.rs b/src/lib.rs index 2d76482..7a3a108 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -400,7 +400,32 @@ impl<'a, 'b> Rem<&'b BigDecimal> for &'a BigDecimal { impl fmt::Display for BigDecimal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.pad_integral(true, "", &self.int_va...
1
26
1
e70c818fce4ef9a3a016eb92b20755cece543dad
Andrew Kubera
2016-10-05T19:06:38
Re-implemented `ten_to_the` to be recursive (and MUCH more efficient)
diff --git a/src/lib.rs b/src/lib.rs index 535dfb6..2d76482 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,16 +36,15 @@ extern crate num_traits as traits; use num::{bigint, integer}; -use std::default::Default; +use std::fmt; +use integer::Integer; use std::error::Error; -use std::num::{ParseFloatError, ParseInt...
1
41
47
d2e419edd85af1aeb69117e97f5d3843cfdce69b
Andrew Kubera
2016-10-05T16:55:54
ParseBigDecimalError::Other - Now wraps a String containing the error message. Return error if radix ≠ 10 in from_str_radix
diff --git a/src/lib.rs b/src/lib.rs index 288ff64..535dfb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -192,7 +192,7 @@ pub enum ParseBigDecimalError { ParseInt(ParseIntError), ParseBigInt(ParseBigIntError), Empty, - Other, + Other(String), } impl fmt::Display for ParseBigDecimalError { @@ -20...
1
6
3
b0ab9ace6e4bbf6a1acd620fd222cb7c44b87c11
Andrew Kubera
2016-10-05T12:06:15
Renamed set_scale to `with_scale` to avoid misinterpretation. Reimplemented Add, Sub, & Mul to minimize cloning and support all sized BigDecimals
diff --git a/src/lib.rs b/src/lib.rs index 7e28901..288ff64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,6 @@ use std::num::{ParseFloatError, ParseIntError}; use std::ops::{Add, Div, Mul, Rem, Sub}; use std::str::{self, FromStr}; use std::fmt; -use std::cmp::max; use bigint::{BigInt, ParseBigIntError}; us...
1
56
27
39d6251cc4f6fc07daf3c7a86523eaa69b396f80
Andrew Kubera
2016-09-26T06:09:17
Implemented ParseBigDecimalError variants for integer & BigInt errors. Removed `split_at` usage in favor of slices.
diff --git a/src/lib.rs b/src/lib.rs index bb55c4e..7e28901 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and ...
1
23
20
310ea65a4ee4fc8e5323b683107686c81da4ce0e
Andrew Kubera
2016-09-21T01:26:02
Fully removed underscore support and slightly simplified the decimal_offset algorithm.
diff --git a/src/lib.rs b/src/lib.rs index fa547dc..bb55c4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -400,14 +400,15 @@ impl Num for BigDecimal { // split slice into base and exponent parts let (base_part, exponent_value) = match s.find(exp_separator) { + // exponent defaults to 0 if (...
1
6
11
4e51538c66ade7afa0f2df3574e29fb97d96887b
Andrew Kubera
2016-09-21T01:05:26
Removed support for underscores in string (deferred to the BigInt parser implementation)
diff --git a/src/lib.rs b/src/lib.rs index 5bd7248..fa547dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -396,10 +396,6 @@ impl Num for BigDecimal { fn from_str_radix(s: &str, radix: u32) -> Result<BigDecimal, ParseBigDecimalError> { assert!(2 <= radix && radix <= 36, "The radix must be within 2...36"); ...
1
8
15
d10358ea5c87e51121fb5874bcf6f06fcfb81599
Andrew Kubera
2016-09-21T00:51:01
Rewrite of from_str_radix method to do less parsing - now searches and splits instead of copying everything into a vector. Added new support for raising i32 parsing errors.
diff --git a/src/lib.rs b/src/lib.rs index 1927328..5bd7248 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,12 +38,12 @@ use num::{bigint, integer}; use std::default::Default; use std::error::Error; -use std::num::ParseFloatError; +use std::num::{ParseFloatError, ParseIntError}; use std::ops::{Add, Div, Mul, Rem, ...
1
56
80
634f081be12413c82f1ec8f5741f334e30e84bed
Andrew Kubera
2016-09-20T19:32:08
Changed parsing error-handling from panicing to returning Err Results. Empty string now returns error (instead of zero). Added tests to test bad strings
diff --git a/src/lib.rs b/src/lib.rs index 313a5f7..1927328 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,6 +172,7 @@ impl BigDecimal { #[derive(Debug, PartialEq)] pub enum ParseBigDecimalError { ParseDecimal(ParseFloatError), + Empty, Other, } @@ -179,6 +180,7 @@ impl fmt::Display for ParseBigDeci...
1
49
7
3375f0b49d31ebd7ded40c5f4efe3e05cc0cd00a
Andrew Kubera
2016-09-20T18:38:32
Added some more tests, and `from_str_radix` will now panic if exponent is not a valid integer.
diff --git a/src/lib.rs b/src/lib.rs index 0b98b41..313a5f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -456,7 +456,13 @@ impl Num for BigDecimal { }; // modify scale by examining remaining characters (exponent) - let scale = scale - i64::from_str(chars.as_str()).unwrap_or(0); + let re...
1
14
1
942fdf7e92d97a6919d8af99c28f7a64d6626a56
Andrew Kubera
2016-09-16T16:24:57
Added equality tests to ensure that == works properly. Fixed implementation of eq() so BigDecimals with large scale differences are compared correctly
diff --git a/src/lib.rs b/src/lib.rs index a6aae5b..0b98b41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -221,14 +221,27 @@ impl PartialEq for BigDecimal { // rhs.int_val, // rhs.scale); + // difference in scale between the two decimals let scale_diff = (self.scale -...
1
44
3
adf25339435b6a8eb6ba5fde339f4e8ce4494436
Andrew Kubera
2016-09-16T15:57:07
Added more test conditions for math operators
diff --git a/src/lib.rs b/src/lib.rs index 5e7b1d8..a6aae5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -461,48 +461,68 @@ impl Num for BigDecimal { #[cfg(test)] mod bigdecimal_tests { use super::BigDecimal; - use bigint::BigInt; - use traits::{Num, ToPrimitive}; - + use traits::ToPrimitive; use st...
1
50
30
670e3023a13e152673cc5ffb61ffea868cb247cb
Andrew Kubera
2016-09-16T15:45:11
Rewrote equality test to correct for scale differences. Added support for exponential form in from_str.
diff --git a/src/lib.rs b/src/lib.rs index 7520225..5e7b1d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,6 @@ use std::num::ParseFloatError; use std::ops::{Add, Div, Mul, Rem, Sub}; use std::str::{self, FromStr}; use std::fmt; -use std::cmp::Ordering::Equal; use std::cmp::max; use bigint::{BigInt, BigUint...
1
69
44
469caca33c5b7c13cc61dfc5d170acbe30f9d69d
Andrew Kubera
2016-09-16T08:04:55
Implemented a correct version of divide.
diff --git a/src/lib.rs b/src/lib.rs index a22e63d..7520225 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,7 @@ extern crate serde; extern crate num; extern crate num_traits as traits; -use num::bigint; +use num::{bigint, integer}; use std::default::Default; use std::error::Error; @@ -45,8 +45,8 @@ use s...
1
46
12
33d821be8890bf153e5200d64655113a4a31a830
Andrew Kubera
2016-09-16T06:58:01
Reimplemented from_str_radix to handle decimal points correctly
diff --git a/src/lib.rs b/src/lib.rs index cbbadbb..a22e63d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,7 +44,7 @@ use std::str::{self, FromStr}; use std::fmt; use std::cmp::Ordering::Equal; use std::cmp::max; -use bigint::{BigInt, ParseBigIntError}; +use bigint::{BigInt, BigUint, ParseBigIntError, Sign}; use t...
1
99
23
ff16d1955debad813e1e72416b2b4f880bc4ebe0
Andrew Kubera
2016-09-14T01:09:14
Updated documentation and fixed some unit-tests
diff --git a/src/lib.rs b/src/lib.rs index 0921c93..cbbadbb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,67 +10,22 @@ //! A Big decimal //! -//! A `BigDecimal` is represented as a vector of `BigDigit`s. +//! BigDecimal allows storing any real number to arbitrary precision; which +//! avoids common floating point...
1
55
83