@@ -216,6 +216,13 @@ pub fn f32_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
216
216
// 10^18 * 0.314159231156617216
217
217
check_shortest ! ( f( 3.141592e17f32 ) => b"3141592" , 18 ) ;
218
218
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
+
219
226
// 10^39 * 0.340282326356119256160033759537265639424
220
227
// 10^39 * 0.34028234663852885981170418348451692544
221
228
// 10^39 * 0.340282366920938463463374607431768211456
@@ -308,6 +315,13 @@ pub fn f64_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
308
315
// 10^18 * 0.314159200000000064
309
316
check_shortest ! ( f( 3.141592e17f64 ) => b"3141592" , 18 ) ;
310
317
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
+
311
325
// pathological case: high = 10^23 (exact). tie breaking should always prefer that.
312
326
// 10^24 * 0.099999999999999974834176
313
327
// 10^24 * 0.099999999999999991611392
@@ -492,15 +506,15 @@ pub fn f32_exhaustive_equivalence_test<F, G>(f: F, g: G, k: usize)
492
506
// so why not simply testing all of them?
493
507
//
494
508
// 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.
496
510
497
511
// iterate from 0x0000_0001 to 0x7f7f_ffff, i.e. all finite ranges
498
512
let ( npassed, nignored) = iterate ( "f32_exhaustive_equivalence_test" ,
499
513
k, 0x7f7f_ffff , f, g, |i : usize | {
500
514
let x: f32 = unsafe { mem:: transmute ( i as u32 + 1 ) } ;
501
515
decode_finite ( x)
502
516
} ) ;
503
- assert_eq ! ( ( npassed, nignored) , ( 2121451879 , 17643160 ) ) ;
517
+ assert_eq ! ( ( npassed, nignored) , ( 2121451881 , 17643158 ) ) ;
504
518
}
505
519
506
520
fn to_string_with_parts < F > ( mut f : F ) -> String
0 commit comments