numerical/
base_float.rs

1/// Base float functions including those not supported in core
2pub trait BaseFloat: core_float::core_float_traits::CoreFloat {
3    fn abs(self) -> Self;
4    fn signum(self) -> Self;
5
6    #[inline]
7    fn sig_ne(self, other: Self) -> bool {
8        self.signum() * other.signum() == -Self::ONE
9    }
10    #[inline]
11    fn sig_eq(self, other: Self) -> bool {
12        self.signum() * other.signum() == Self::ONE
13    }
14}
15
16impl BaseFloat for f32 {
17    #[inline]
18    fn abs(self) -> Self {
19        <f32>::abs(self)
20    }
21    #[inline]
22    fn signum(self) -> Self {
23        <f32>::signum(self)
24    }
25}
26
27impl BaseFloat for f64 {
28    #[inline]
29    fn abs(self) -> Self {
30        <f64>::abs(self)
31    }
32    #[inline]
33    fn signum(self) -> Self {
34        <f64>::signum(self)
35    }
36}