diff options
| author | Robin Kruppe <robin.kruppe@gmail.com> | 2015-07-23 22:18:44 +0200 |
|---|---|---|
| committer | Robin Kruppe <robin.kruppe@gmail.com> | 2015-08-08 17:15:14 +0200 |
| commit | 7ff10209aa9b8da6d6d4ceea0161757048126d2d (patch) | |
| tree | d82adfeeb1e659c40342627f5d8b4978e00f0d73 /src/libcore/num | |
| parent | b55806ca8ff97ee89f77f9c784619ace3034c32c (diff) | |
| download | rust-7ff10209aa9b8da6d6d4ceea0161757048126d2d.tar.gz rust-7ff10209aa9b8da6d6d4ceea0161757048126d2d.zip | |
Enlarge Bignum type from 1152 to 1280 bits.
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.
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/flt2dec/bignum.rs | 10 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/dragon.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/libcore/num/flt2dec/bignum.rs b/src/libcore/num/flt2dec/bignum.rs index 1e39c53f9e0..33c5a3ded98 100644 --- a/src/libcore/num/flt2dec/bignum.rs +++ b/src/libcore/num/flt2dec/bignum.rs @@ -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 @@ macro_rules! define_bignum { ) } -/// 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)] diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index b03286ddd0d..cdc23c45fa0 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -23,7 +23,7 @@ use cmp::Ordering; 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]; |
