--- a/rust/fpnum/src/lib.rs Sat Jul 06 22:04:59 2019 +0300
+++ b/rust/fpnum/src/lib.rs Mon Jul 08 15:16:05 2019 +0300
@@ -131,9 +131,9 @@
#[inline]
fn from(n: FPNum) -> Self {
if n.is_negative() {
- n.value as f64 / (-0x10000000 as f64)
+ n.value as f64 / -0x1_0000_0000i64 as f64
} else {
- n.value as f64 / 0x10000000 as f64
+ n.value as f64 / 0x1_0000_0000i64 as f64
}
}
}
@@ -539,6 +539,8 @@
assert_eq!(n.round(), 7);
assert_eq!((-n).round(), -7);
+
+ assert_eq!(f64::from(fp!(5/2)), 2.5f64);
}
#[test]