statime/
float_polyfill.rs1#[allow(unused)] pub(crate) trait FloatPolyfill {
3 #[cfg(not(feature = "std"))]
4 fn abs(self) -> Self;
5 #[cfg(not(feature = "std"))]
6 fn signum(self) -> Self;
7 #[cfg(not(feature = "std"))]
8 fn sqrt(self) -> Self;
9 #[cfg(not(feature = "std"))]
10 fn powi(self, n: i32) -> Self;
11 #[cfg(not(feature = "std"))]
12 fn exp(self) -> Self;
13}
14
15impl FloatPolyfill for f64 {
16 #[cfg(not(feature = "std"))]
17 fn abs(self) -> Self {
18 libm::fabs(self)
19 }
20
21 #[cfg(not(feature = "std"))]
22 fn signum(self) -> Self {
23 if self < 0.0 {
24 -1.0
25 } else if self > 0.0 {
26 1.0
27 } else {
28 0.0
29 }
30 }
31
32 #[cfg(not(feature = "std"))]
33 fn sqrt(self) -> Self {
34 libm::sqrt(self)
35 }
36
37 #[cfg(not(feature = "std"))]
38 fn powi(self, n: i32) -> Self {
39 libm::pow(self, n as f64)
40 }
41
42 #[cfg(not(feature = "std"))]
43 fn exp(self) -> Self {
44 libm::exp(self)
45 }
46}