@@ -216,6 +216,13 @@ pub fn f32_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
216216 // 10^18 * 0.314159231156617216
217217 check_shortest ! ( f( 3.141592e17f32 ) => b"3141592" , 18 ) ;
218218
219+ // regression test for decoders
220+ // 10^8 * 0.3355443
221+ // 10^8 * 0.33554432
222+ // 10^8 * 0.33554436
223+ let twoto25: f32 = StdFloat :: ldexp ( 1.0 , 25 ) ;
224+ check_shortest ! ( f( twoto25) => b"33554432" , 8 ) ;
225+
219226 // 10^39 * 0.340282326356119256160033759537265639424
220227 // 10^39 * 0.34028234663852885981170418348451692544
221228 // 10^39 * 0.340282366920938463463374607431768211456
@@ -308,6 +315,13 @@ pub fn f64_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
308315 // 10^18 * 0.314159200000000064
309316 check_shortest ! ( f( 3.141592e17f64 ) => b"3141592" , 18 ) ;
310317
318+ // regression test for decoders
319+ // 10^20 * 0.18446744073709549568
320+ // 10^20 * 0.18446744073709551616
321+ // 10^20 * 0.18446744073709555712
322+ let twoto64: f64 = StdFloat :: ldexp ( 1.0 , 64 ) ;
323+ check_shortest ! ( f( twoto64) => b"18446744073709552" , 20 ) ;
324+
311325 // pathological case: high = 10^23 (exact). tie breaking should always prefer that.
312326 // 10^24 * 0.099999999999999974834176
313327 // 10^24 * 0.099999999999999991611392
@@ -492,15 +506,15 @@ pub fn f32_exhaustive_equivalence_test<F, G>(f: F, g: G, k: usize)
492506 // so why not simply testing all of them?
493507 //
494508 // this is of course very stressful (and thus should be behind an `#[ignore]` attribute),
495- // but with `-O3 - C lto` this only takes about two hours or so.
509+ // but with `-C opt-level=3 - C lto` this only takes about an hour or so.
496510
497511 // iterate from 0x0000_0001 to 0x7f7f_ffff, i.e. all finite ranges
498512 let ( npassed, nignored) = iterate ( "f32_exhaustive_equivalence_test" ,
499513 k, 0x7f7f_ffff , f, g, |i : usize | {
500514 let x: f32 = unsafe { mem:: transmute ( i as u32 + 1 ) } ;
501515 decode_finite ( x)
502516 } ) ;
503- assert_eq ! ( ( npassed, nignored) , ( 2121451879 , 17643160 ) ) ;
517+ assert_eq ! ( ( npassed, nignored) , ( 2121451881 , 17643158 ) ) ;
504518}
505519
506520fn to_string_with_parts < F > ( mut f : F ) -> String
0 commit comments