@@ -21,9 +21,8 @@ use super::num::{self, Big};
21
21
/// Number of significand bits in Fp
22
22
const P : u32 = 64 ;
23
23
24
- // We simply store the best approximation for *all* exponents, so
25
- // the variable "h" and the associated conditions can be omitted.
26
- // This trades performance for space (11 KiB versus... 5 KiB or so?)
24
+ // We simply store the best approximation for *all* exponents, so the variable "h" and the
25
+ // associated conditions can be omitted. This trades performance for a couple kilobytes of space.
27
26
28
27
fn power_of_ten ( e : i16 ) -> Fp {
29
28
assert ! ( e >= table:: MIN_E ) ;
@@ -37,6 +36,15 @@ fn power_of_ten(e: i16) -> Fp {
37
36
///
38
37
/// This is extracted into a separate function so that it can be attempted before constructing
39
38
/// a bignum.
39
+ ///
40
+ /// The fast path crucially depends on arithmetic being correctly rounded, so on x86
41
+ /// without SSE or SSE2 it will be **wrong** (as in, off by one ULP occasionally), because the x87
42
+ /// FPU stack will round to 80 bit first before rounding to 64/32 bit. However, as such hardware
43
+ /// is extremely rare nowadays and in fact all in-tree target triples assume an SSE2-capable
44
+ /// microarchitecture, there is little incentive to deal with that. There's a test that will fail
45
+ /// when SSE or SSE2 is disabled, so people building their own non-SSE copy will get a heads up.
46
+ ///
47
+ /// FIXME: It would nevertheless be nice if we had a good way to detect and deal with x87.
40
48
pub fn fast_path < T : RawFloat > ( integral : & [ u8 ] , fractional : & [ u8 ] , e : i64 ) -> Option < T > {
41
49
let num_digits = integral. len ( ) + fractional. len ( ) ;
42
50
// log_10(f64::max_sig) ~ 15.95. We compare the exact value to max_sig near the end,
0 commit comments