1 #![cfg(feature = "compact")]
2 #![allow(dead_code)]
3
4 use minimal_lexical::bellerophon::bellerophon;
5 use minimal_lexical::extended_float::{extended_to_float, ExtendedFloat};
6 use minimal_lexical::num::Float;
7 use minimal_lexical::number::Number;
8
bellerophon_test<F: Float + core::fmt::Debug>( xmant: u64, xexp: i32, many_digits: bool, ymant: u64, yexp: i32, )9 pub fn bellerophon_test<F: Float + core::fmt::Debug>(
10 xmant: u64,
11 xexp: i32,
12 many_digits: bool,
13 ymant: u64,
14 yexp: i32,
15 ) {
16 let num = Number {
17 exponent: xexp,
18 mantissa: xmant,
19 many_digits,
20 };
21 let xfp = bellerophon::<F>(&num);
22 let yfp = ExtendedFloat {
23 mant: ymant,
24 exp: yexp,
25 };
26 // Given us useful error messages if the floats are valid.
27 if xfp.exp >= 0 && yfp.exp >= 0 {
28 assert!(
29 xfp == yfp,
30 "x != y, xfp={:?}, yfp={:?}, x={:?}, y={:?}",
31 xfp,
32 yfp,
33 extended_to_float::<F>(xfp),
34 extended_to_float::<F>(yfp)
35 );
36 } else {
37 assert_eq!(xfp, yfp);
38 }
39 }
40
compute_float32(q: i32, w: u64) -> (i32, u64)41 pub fn compute_float32(q: i32, w: u64) -> (i32, u64) {
42 let num = Number {
43 exponent: q,
44 mantissa: w,
45 many_digits: false,
46 };
47 let fp = bellerophon::<f32>(&num);
48 (fp.exp, fp.mant)
49 }
50
compute_float64(q: i32, w: u64) -> (i32, u64)51 pub fn compute_float64(q: i32, w: u64) -> (i32, u64) {
52 let num = Number {
53 exponent: q,
54 mantissa: w,
55 many_digits: false,
56 };
57 let fp = bellerophon::<f64>(&num);
58 (fp.exp, fp.mant)
59 }
60