]> git.lizzy.rs Git - rust.git/commitdiff
Enlarge Bignum type from 1152 to 1280 bits.
authorRobin Kruppe <robin.kruppe@gmail.com>
Thu, 23 Jul 2015 20:18:44 +0000 (22:18 +0200)
committerRobin Kruppe <robin.kruppe@gmail.com>
Sat, 8 Aug 2015 15:15:14 +0000 (17:15 +0200)
This is necessary for decimal-to-float code (in a later commit) to handle
inputs such as 4.9406564584124654e-324 (the smallest subnormal f64).
According to the benchmarks for flt2dec::dragon, this does not
affect performance measurably. It probably uses slightly more stack
space though.

src/libcore/num/flt2dec/bignum.rs
src/libcore/num/flt2dec/strategy/dragon.rs
src/libcoretest/num/flt2dec/strategy/dragon.rs

index 1e39c53f9e06a6df417e695c7b2f23d100212609..33c5a3ded980fe0547d76477a7618114ec99e785 100644 (file)
@@ -11,9 +11,9 @@
 //! Custom arbitrary-precision number (bignum) implementation.
 //!
 //! This is designed to avoid the heap allocation at expense of stack memory.
-//! The most used bignum type, `Big32x36`, is limited by 32 × 36 = 1,152 bits
-//! and will take at most 152 bytes of stack memory. This is (barely) enough
-//! for handling all possible finite `f64` values.
+//! The most used bignum type, `Big32x40`, is limited by 32 × 40 = 1,280 bits
+//! and will take at most 160 bytes of stack memory. This is more than enough
+//! for formatting and parsing all possible finite `f64` values.
 //!
 //! In principle it is possible to have multiple bignum types for different
 //! inputs, but we don't do so to avoid the code bloat. Each bignum is still
@@ -344,10 +344,10 @@ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
     )
 }
 
-/// The digit type for `Big32x36`.
+/// The digit type for `Big32x40`.
 pub type Digit32 = u32;
 
-define_bignum!(Big32x36: type=Digit32, n=36);
+define_bignum!(Big32x40: type=Digit32, n=40);
 
 // this one is used for testing only.
 #[doc(hidden)]
index b03286ddd0dc2b9a80fec549f3dd546860bde448..cdc23c45fa0b6c073dace4c3a54f119f0591d02e 100644 (file)
@@ -23,7 +23,7 @@
 use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up};
 use num::flt2dec::estimator::estimate_scaling_factor;
 use num::flt2dec::bignum::Digit32 as Digit;
-use num::flt2dec::bignum::Big32x36 as Big;
+use num::flt2dec::bignum::Big32x40 as Big;
 
 static POW10: [Digit; 10] = [1, 10, 100, 1000, 10000, 100000,
                              1000000, 10000000, 100000000, 1000000000];
index f2397f6b48037e0311bfb5a257db741b7f1087d9..26bb5b9d9c5bc044defb923df477a46ed7d305a4 100644 (file)
@@ -12,7 +12,7 @@
 use std::{i16, f64};
 use super::super::*;
 use core::num::flt2dec::*;
-use core::num::flt2dec::bignum::Big32x36 as Big;
+use core::num::flt2dec::bignum::Big32x40 as Big;
 use core::num::flt2dec::strategy::dragon::*;
 
 #[test]