basic/
basic.rs

1use fixed2float::to_fixed;
2use fixed2float::{to_Fx, to_Q, to_float, to_float_str, FixedPoint, Fx, Q};
3
4fn main() {
5  // let bits = "1010000010110000";
6  // let (m, n) = (1, 15);
7
8  // let b1 = to_Q(0.0, 1, 5, true).unwrap();
9  // println!("{b1:?}");
10
11  // let x = to_float_str(bits, m, n);
12  // println!("bits = {} -> {:?}", bits, x);
13
14  // let bits = 0b1010000010110000;
15  // let x = to_float(bits, 16, m, n);
16  // println!("{:?}", x);
17
18  // let x = 10.25;
19  // let (m, n) = (21, 3);
20
21  // let fx0 = to_Q(x, m, n, true).unwrap();
22  // println!("{:?}", fx0);
23
24  // let fx1 = Q::new(0b10010011, 6, 2, true); // 36.75
25  // let fx2 = Fx::new(0b10010011, 6, 8, true); // 36.75
26
27  // println!("{:?} {} {}", fx1, fx1, fx1.eval());
28  // println!("{:?} {} {}", fx2, fx2, fx2.eval());
29
30  // // let fx1_sliced = fx1.index(7..0);
31  // // println!("{:?}", fx1_sliced);
32
33  // let fx33 = to_Fx(-2.44140625, 4, 12, true);
34  // println!("{fx33:?}");
35
36  // let fixed11 = to_fixed(-2.5, 3, 3, false);
37  // println!("{:?}", fixed11);
38
39  // let fixed22 = to_Fx(10.0, 4, 15, false);
40  // println!("{:?}", fixed22);
41
42  // let fixed23 = to_Fx(5.8, 4, 15, false);
43  // println!("{:?}", fixed23);
44
45  // println!("{:?}", fixed22.unwrap() + fixed23.unwrap());
46
47  // println!("{:?}", to_float(0b1_000, 4, 3, 0));
48
49  // let a = Fx::new(0b11111111111111111111110010100000010001001011000100100110000000000000000000000000000000000000000000000000000000000000000000000000, 31, 128, true);
50  // println!("{:?}", a.eval());
51
52  let m1 = Fx::new(0b0_0001_100, 4, 8, true);
53  let m2 = Fx::new(0b1_1101_010, 4, 8, true);
54  let m = m1 * m2;
55  println!("{:?}", m);
56}