--- a/rust/fpnum/src/lib.rs Sat Oct 13 00:43:04 2018 +0300
+++ b/rust/fpnum/src/lib.rs Sat Oct 13 18:04:25 2018 +0200
@@ -12,6 +12,7 @@
FPNum::from(numerator) / denominator
}
+ #[inline]
fn signum(&self) -> i8 {
if self.is_negative {
-1
@@ -20,18 +21,22 @@
}
}
+ #[inline]
fn is_negative(&self) -> bool {
self.is_negative
}
+ #[inline]
fn is_positive(&self) -> bool {
!self.is_negative
}
+ #[inline]
fn is_zero(&self) -> bool {
self.value == 0
}
+ #[inline]
fn abs(&self) -> Self {
Self {
is_negative: false,
@@ -39,6 +44,7 @@
}
}
+ #[inline]
fn round(&self) -> i64 {
if self.is_negative {
-((self.value >> 32) as i64)
@@ -47,6 +53,7 @@
}
}
+ #[inline]
fn sqr(&self) -> Self {
Self {
is_negative: false,
@@ -111,6 +118,7 @@
}
impl PartialEq for FPNum {
+ #[inline]
fn eq(&self, other: &Self) -> bool {
self.value == other.value && (self.is_negative == other.is_negative || self.value == 0)
}
@@ -119,6 +127,7 @@
impl Eq for FPNum {}
impl PartialOrd for FPNum {
+ #[inline]
fn partial_cmp(&self, rhs: &Self) -> std::option::Option<std::cmp::Ordering> {
Some(self.cmp(rhs))
}