float_polyfills/
float_64.rs1pub trait F64Polyfill: Sized {
3 fn abs(self) -> f64;
5
6 fn acos(self) -> f64;
8
9 fn asin(self) -> f64;
11
12 fn atan(self) -> f64;
14
15 fn atan2(self, other: f64) -> f64;
17
18 fn ceil(self) -> f64;
20
21 fn copysign(self, sign: f64) -> f64;
23
24 fn cos(self) -> f64;
26
27 fn exp(self) -> f64;
29
30 fn floor(self) -> f64;
32
33 fn hypot(self, other: f64) -> f64;
37
38 fn ln(self) -> f64;
40
41 fn log2(self) -> f64;
43
44 fn log10(self) -> f64;
46
47 fn mul_add(self, a: f64, b: f64) -> f64;
49
50 fn powf(self, n: f64) -> f64;
52
53 fn powi(self, n: i64) -> f64;
55
56 fn recip(self) -> f64;
58
59 fn round(self) -> f64;
62
63 fn sin(self) -> f64;
65
66 fn sin_cos(self) -> (f64, f64);
68
69 fn sqrt(self) -> f64;
71
72 fn tan(self) -> f64;
74
75 fn trunc(self) -> f64;
78}
79
80
81impl F64Polyfill for f64 {
82 fn abs(self) -> f64 {
83 libm::fabs(self)
84 }
85
86 fn acos(self) -> f64 {
87 libm::acos(self)
88 }
89
90 fn asin(self) -> f64 {
91 libm::asin(self)
92 }
93
94 fn atan(self) -> f64 {
95 libm::atan(self)
96 }
97
98 fn atan2(self, other: f64) -> f64 {
99 libm::atan2(self, other)
100 }
101
102 fn ceil(self) -> f64 {
103 libm::ceil(self)
104 }
105
106 fn copysign(self, sign: f64) -> f64 {
107 libm::copysign(self, sign)
108 }
109
110 fn cos(self) -> f64 {
111 libm::cos(self)
112 }
113
114 fn exp(self) -> f64 {
115 libm::exp(self)
116 }
117
118 fn floor(self) -> f64 {
119 libm::floor(self)
120 }
121
122 fn hypot(self, other: f64) -> f64 {
123 libm::hypot(self, other)
124 }
125
126 fn ln(self) -> f64 {
127 libm::log(self)
128 }
129
130 fn log2(self) -> f64 {
131 libm::log2(self)
132 }
133
134 fn log10(self) -> f64 {
135 libm::log10(self)
136 }
137
138 fn mul_add(self, a: f64, b: f64) -> f64 {
139 (self * a) + b
140 }
141
142 fn powf(self, n: f64) -> f64 {
143 libm::pow(self, n)
144 }
145
146 fn powi(self, n: i64) -> f64 {
147 libm::pow(self, n as f64)
148 }
149
150 fn recip(self) -> f64 {
151 1.0/self
152 }
153
154 fn round(self) -> f64 {
155 libm::round(self)
156 }
157
158 fn sin(self) -> f64 {
159 libm::sin(self)
160 }
161
162 fn sin_cos(self) -> (f64, f64) {
163 libm::sincos(self)
164 }
165
166 fn sqrt(self) -> f64 {
167 libm::sqrt(self)
168 }
169
170 fn tan(self) -> f64 {
171 libm::tan(self)
172 }
173
174 fn trunc(self) -> f64 {
175 libm::trunc(self)
176 }
177}