authorgravatar for bratishkaerik@getgoogleoff.meEric Joldasov <bratishkaerik@getgoogleoff.me> 2023-06-04 23:09:17+06:00
committergravatar for bratishkaerik@getgoogleoff.meEric Joldasov <bratishkaerik@getgoogleoff.me> 2023-06-13 23:45:12+06:00
logd04a262a3d7e68920dec2a6becc86bf79d81452c
tree7b839339d5a11e493cb6ffb58626005f94e98ea2
parenteb4439f1e4e617247bffff13478a9fa57160c507
signaturelock-open Commit is signed but in an unrecognized format.

std.math: hard deprecate obsolete constants (soft deprecated in 0.10)

Followup to 5b8ac9821dd25c3e5282130b4d93d6c5b7debb08. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>

5 files changed, 361 insertions(+), 273 deletions(-)

lib/compiler_rt/powiXf2_test.zig+235-230
......@@ -32,17 +32,18 @@ fn test__powixf2(a: f80, b: i32, expected: f80) !void {
3232}
3333
3434test "powihf2" {
35 const inf_f16 = math.inf(f16);
3536 try test__powisf2(0, 0, 1);
3637 try test__powihf2(1, 0, 1);
3738 try test__powihf2(1.5, 0, 1);
3839 try test__powihf2(2, 0, 1);
39 try test__powihf2(math.inf_f16, 0, 1);
40 try test__powihf2(inf_f16, 0, 1);
4041
4142 try test__powihf2(-0.0, 0, 1);
4243 try test__powihf2(-1, 0, 1);
4344 try test__powihf2(-1.5, 0, 1);
4445 try test__powihf2(-2, 0, 1);
45 try test__powihf2(-math.inf_f16, 0, 1);
46 try test__powihf2(-inf_f16, 0, 1);
4647
4748 try test__powihf2(0, 1, 0);
4849 try test__powihf2(0, 2, 0);
......@@ -65,35 +66,35 @@ test "powihf2" {
6566 try test__powihf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
6667 try test__powihf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
6768
68 try test__powihf2(math.inf_f16, 1, math.inf_f16);
69 try test__powihf2(math.inf_f16, 2, math.inf_f16);
70 try test__powihf2(math.inf_f16, 3, math.inf_f16);
71 try test__powihf2(math.inf_f16, 4, math.inf_f16);
72 try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f16);
73 try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f16);
74
75 try test__powihf2(-math.inf_f16, 1, -math.inf_f16);
76 try test__powihf2(-math.inf_f16, 2, math.inf_f16);
77 try test__powihf2(-math.inf_f16, 3, -math.inf_f16);
78 try test__powihf2(-math.inf_f16, 4, math.inf_f16);
79 try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f16);
80 try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f16);
69 try test__powihf2(inf_f16, 1, inf_f16);
70 try test__powihf2(inf_f16, 2, inf_f16);
71 try test__powihf2(inf_f16, 3, inf_f16);
72 try test__powihf2(inf_f16, 4, inf_f16);
73 try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f16);
74 try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f16);
75
76 try test__powihf2(-inf_f16, 1, -inf_f16);
77 try test__powihf2(-inf_f16, 2, inf_f16);
78 try test__powihf2(-inf_f16, 3, -inf_f16);
79 try test__powihf2(-inf_f16, 4, inf_f16);
80 try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f16);
81 try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f16);
8182 //
82 try test__powihf2(0, -1, math.inf_f16);
83 try test__powihf2(0, -2, math.inf_f16);
84 try test__powihf2(0, -3, math.inf_f16);
85 try test__powihf2(0, -4, math.inf_f16);
86 try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f16); // 0 ^ anything = +inf
87 try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f16);
88 try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f16);
89
90 try test__powihf2(-0.0, -1, -math.inf_f16);
91 try test__powihf2(-0.0, -2, math.inf_f16);
92 try test__powihf2(-0.0, -3, -math.inf_f16);
93 try test__powihf2(-0.0, -4, math.inf_f16);
94 try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f16); // -0 ^ anything even = +inf
95 try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f16); // -0 ^ anything odd = -inf
96 try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f16);
83 try test__powihf2(0, -1, inf_f16);
84 try test__powihf2(0, -2, inf_f16);
85 try test__powihf2(0, -3, inf_f16);
86 try test__powihf2(0, -4, inf_f16);
87 try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f16); // 0 ^ anything = +inf
88 try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f16);
89 try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f16);
90
91 try test__powihf2(-0.0, -1, -inf_f16);
92 try test__powihf2(-0.0, -2, inf_f16);
93 try test__powihf2(-0.0, -3, -inf_f16);
94 try test__powihf2(-0.0, -4, inf_f16);
95 try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f16); // -0 ^ anything even = +inf
96 try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f16); // -0 ^ anything odd = -inf
97 try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f16);
9798
9899 try test__powihf2(1, -1, 1);
99100 try test__powihf2(1, -2, 1);
......@@ -103,21 +104,21 @@ test "powihf2" {
103104 try test__powihf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
104105 try test__powihf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
105106
106 try test__powihf2(math.inf_f16, -1, 0);
107 try test__powihf2(math.inf_f16, -2, 0);
108 try test__powihf2(math.inf_f16, -3, 0);
109 try test__powihf2(math.inf_f16, -4, 0);
110 try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
111 try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000001)), 0);
112 try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
107 try test__powihf2(inf_f16, -1, 0);
108 try test__powihf2(inf_f16, -2, 0);
109 try test__powihf2(inf_f16, -3, 0);
110 try test__powihf2(inf_f16, -4, 0);
111 try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
112 try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000001)), 0);
113 try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
113114 //
114 try test__powihf2(-math.inf_f16, -1, -0.0);
115 try test__powihf2(-math.inf_f16, -2, 0);
116 try test__powihf2(-math.inf_f16, -3, -0.0);
117 try test__powihf2(-math.inf_f16, -4, 0);
118 try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
119 try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
120 try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
115 try test__powihf2(-inf_f16, -1, -0.0);
116 try test__powihf2(-inf_f16, -2, 0);
117 try test__powihf2(-inf_f16, -3, -0.0);
118 try test__powihf2(-inf_f16, -4, 0);
119 try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
120 try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
121 try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
121122
122123 try test__powihf2(2, 10, 1024.0);
123124 try test__powihf2(-2, 10, 1024.0);
......@@ -128,8 +129,8 @@ test "powihf2" {
128129 try test__powihf2(-2, 14, 16384.0);
129130 try test__powihf2(2, 15, 32768.0);
130131 try test__powihf2(-2, 15, -32768.0);
131 try test__powihf2(2, 16, math.inf_f16);
132 try test__powihf2(-2, 16, math.inf_f16);
132 try test__powihf2(2, 16, inf_f16);
133 try test__powihf2(-2, 16, inf_f16);
133134
134135 try test__powihf2(2, -13, 1.0 / 8192.0);
135136 try test__powihf2(-2, -13, -1.0 / 8192.0);
......@@ -140,17 +141,18 @@ test "powihf2" {
140141}
141142
142143test "powisf2" {
144 const inf_f32 = math.inf(f32);
143145 try test__powisf2(0, 0, 1);
144146 try test__powisf2(1, 0, 1);
145147 try test__powisf2(1.5, 0, 1);
146148 try test__powisf2(2, 0, 1);
147 try test__powisf2(math.inf_f32, 0, 1);
149 try test__powisf2(inf_f32, 0, 1);
148150
149151 try test__powisf2(-0.0, 0, 1);
150152 try test__powisf2(-1, 0, 1);
151153 try test__powisf2(-1.5, 0, 1);
152154 try test__powisf2(-2, 0, 1);
153 try test__powisf2(-math.inf_f32, 0, 1);
155 try test__powisf2(-inf_f32, 0, 1);
154156
155157 try test__powisf2(0, 1, 0);
156158 try test__powisf2(0, 2, 0);
......@@ -173,35 +175,35 @@ test "powisf2" {
173175 try test__powisf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
174176 try test__powisf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
175177
176 try test__powisf2(math.inf_f32, 1, math.inf_f32);
177 try test__powisf2(math.inf_f32, 2, math.inf_f32);
178 try test__powisf2(math.inf_f32, 3, math.inf_f32);
179 try test__powisf2(math.inf_f32, 4, math.inf_f32);
180 try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f32);
181 try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f32);
182
183 try test__powisf2(-math.inf_f32, 1, -math.inf_f32);
184 try test__powisf2(-math.inf_f32, 2, math.inf_f32);
185 try test__powisf2(-math.inf_f32, 3, -math.inf_f32);
186 try test__powisf2(-math.inf_f32, 4, math.inf_f32);
187 try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f32);
188 try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f32);
189
190 try test__powisf2(0, -1, math.inf_f32);
191 try test__powisf2(0, -2, math.inf_f32);
192 try test__powisf2(0, -3, math.inf_f32);
193 try test__powisf2(0, -4, math.inf_f32);
194 try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f32);
195 try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f32);
196 try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f32);
197
198 try test__powisf2(-0.0, -1, -math.inf_f32);
199 try test__powisf2(-0.0, -2, math.inf_f32);
200 try test__powisf2(-0.0, -3, -math.inf_f32);
201 try test__powisf2(-0.0, -4, math.inf_f32);
202 try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f32);
203 try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f32);
204 try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f32);
178 try test__powisf2(inf_f32, 1, inf_f32);
179 try test__powisf2(inf_f32, 2, inf_f32);
180 try test__powisf2(inf_f32, 3, inf_f32);
181 try test__powisf2(inf_f32, 4, inf_f32);
182 try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f32);
183 try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f32);
184
185 try test__powisf2(-inf_f32, 1, -inf_f32);
186 try test__powisf2(-inf_f32, 2, inf_f32);
187 try test__powisf2(-inf_f32, 3, -inf_f32);
188 try test__powisf2(-inf_f32, 4, inf_f32);
189 try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f32);
190 try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f32);
191
192 try test__powisf2(0, -1, inf_f32);
193 try test__powisf2(0, -2, inf_f32);
194 try test__powisf2(0, -3, inf_f32);
195 try test__powisf2(0, -4, inf_f32);
196 try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f32);
197 try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f32);
198 try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f32);
199
200 try test__powisf2(-0.0, -1, -inf_f32);
201 try test__powisf2(-0.0, -2, inf_f32);
202 try test__powisf2(-0.0, -3, -inf_f32);
203 try test__powisf2(-0.0, -4, inf_f32);
204 try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f32);
205 try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f32);
206 try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f32);
205207
206208 try test__powisf2(1, -1, 1);
207209 try test__powisf2(1, -2, 1);
......@@ -211,21 +213,21 @@ test "powisf2" {
211213 try test__powisf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
212214 try test__powisf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
213215
214 try test__powisf2(math.inf_f32, -1, 0);
215 try test__powisf2(math.inf_f32, -2, 0);
216 try test__powisf2(math.inf_f32, -3, 0);
217 try test__powisf2(math.inf_f32, -4, 0);
218 try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
219 try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000001)), 0);
220 try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
221
222 try test__powisf2(-math.inf_f32, -1, -0.0);
223 try test__powisf2(-math.inf_f32, -2, 0);
224 try test__powisf2(-math.inf_f32, -3, -0.0);
225 try test__powisf2(-math.inf_f32, -4, 0);
226 try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
227 try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
228 try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
216 try test__powisf2(inf_f32, -1, 0);
217 try test__powisf2(inf_f32, -2, 0);
218 try test__powisf2(inf_f32, -3, 0);
219 try test__powisf2(inf_f32, -4, 0);
220 try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
221 try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000001)), 0);
222 try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
223
224 try test__powisf2(-inf_f32, -1, -0.0);
225 try test__powisf2(-inf_f32, -2, 0);
226 try test__powisf2(-inf_f32, -3, -0.0);
227 try test__powisf2(-inf_f32, -4, 0);
228 try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
229 try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
230 try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
229231
230232 try test__powisf2(2.0, 10, 1024.0);
231233 try test__powisf2(-2, 10, 1024.0);
......@@ -244,17 +246,18 @@ test "powisf2" {
244246}
245247
246248test "powidf2" {
249 const inf_f64 = math.inf(f64);
247250 try test__powidf2(0, 0, 1);
248251 try test__powidf2(1, 0, 1);
249252 try test__powidf2(1.5, 0, 1);
250253 try test__powidf2(2, 0, 1);
251 try test__powidf2(math.inf_f64, 0, 1);
254 try test__powidf2(inf_f64, 0, 1);
252255
253256 try test__powidf2(-0.0, 0, 1);
254257 try test__powidf2(-1, 0, 1);
255258 try test__powidf2(-1.5, 0, 1);
256259 try test__powidf2(-2, 0, 1);
257 try test__powidf2(-math.inf_f64, 0, 1);
260 try test__powidf2(-inf_f64, 0, 1);
258261
259262 try test__powidf2(0, 1, 0);
260263 try test__powidf2(0, 2, 0);
......@@ -277,35 +280,35 @@ test "powidf2" {
277280 try test__powidf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
278281 try test__powidf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
279282
280 try test__powidf2(math.inf_f64, 1, math.inf_f64);
281 try test__powidf2(math.inf_f64, 2, math.inf_f64);
282 try test__powidf2(math.inf_f64, 3, math.inf_f64);
283 try test__powidf2(math.inf_f64, 4, math.inf_f64);
284 try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f64);
285 try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f64);
286
287 try test__powidf2(-math.inf_f64, 1, -math.inf_f64);
288 try test__powidf2(-math.inf_f64, 2, math.inf_f64);
289 try test__powidf2(-math.inf_f64, 3, -math.inf_f64);
290 try test__powidf2(-math.inf_f64, 4, math.inf_f64);
291 try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f64);
292 try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f64);
293
294 try test__powidf2(0, -1, math.inf_f64);
295 try test__powidf2(0, -2, math.inf_f64);
296 try test__powidf2(0, -3, math.inf_f64);
297 try test__powidf2(0, -4, math.inf_f64);
298 try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f64);
299 try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f64);
300 try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f64);
301
302 try test__powidf2(-0.0, -1, -math.inf_f64);
303 try test__powidf2(-0.0, -2, math.inf_f64);
304 try test__powidf2(-0.0, -3, -math.inf_f64);
305 try test__powidf2(-0.0, -4, math.inf_f64);
306 try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f64);
307 try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f64);
308 try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f64);
283 try test__powidf2(inf_f64, 1, inf_f64);
284 try test__powidf2(inf_f64, 2, inf_f64);
285 try test__powidf2(inf_f64, 3, inf_f64);
286 try test__powidf2(inf_f64, 4, inf_f64);
287 try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f64);
288 try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f64);
289
290 try test__powidf2(-inf_f64, 1, -inf_f64);
291 try test__powidf2(-inf_f64, 2, inf_f64);
292 try test__powidf2(-inf_f64, 3, -inf_f64);
293 try test__powidf2(-inf_f64, 4, inf_f64);
294 try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f64);
295 try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f64);
296
297 try test__powidf2(0, -1, inf_f64);
298 try test__powidf2(0, -2, inf_f64);
299 try test__powidf2(0, -3, inf_f64);
300 try test__powidf2(0, -4, inf_f64);
301 try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f64);
302 try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f64);
303 try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f64);
304
305 try test__powidf2(-0.0, -1, -inf_f64);
306 try test__powidf2(-0.0, -2, inf_f64);
307 try test__powidf2(-0.0, -3, -inf_f64);
308 try test__powidf2(-0.0, -4, inf_f64);
309 try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f64);
310 try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f64);
311 try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f64);
309312
310313 try test__powidf2(1, -1, 1);
311314 try test__powidf2(1, -2, 1);
......@@ -315,21 +318,21 @@ test "powidf2" {
315318 try test__powidf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
316319 try test__powidf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
317320
318 try test__powidf2(math.inf_f64, -1, 0);
319 try test__powidf2(math.inf_f64, -2, 0);
320 try test__powidf2(math.inf_f64, -3, 0);
321 try test__powidf2(math.inf_f64, -4, 0);
322 try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
323 try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000001)), 0);
324 try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
325
326 try test__powidf2(-math.inf_f64, -1, -0.0);
327 try test__powidf2(-math.inf_f64, -2, 0);
328 try test__powidf2(-math.inf_f64, -3, -0.0);
329 try test__powidf2(-math.inf_f64, -4, 0);
330 try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
331 try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
332 try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
321 try test__powidf2(inf_f64, -1, 0);
322 try test__powidf2(inf_f64, -2, 0);
323 try test__powidf2(inf_f64, -3, 0);
324 try test__powidf2(inf_f64, -4, 0);
325 try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
326 try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000001)), 0);
327 try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
328
329 try test__powidf2(-inf_f64, -1, -0.0);
330 try test__powidf2(-inf_f64, -2, 0);
331 try test__powidf2(-inf_f64, -3, -0.0);
332 try test__powidf2(-inf_f64, -4, 0);
333 try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
334 try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
335 try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
333336
334337 try test__powidf2(2, 10, 1024.0);
335338 try test__powidf2(-2, 10, 1024.0);
......@@ -348,17 +351,18 @@ test "powidf2" {
348351}
349352
350353test "powitf2" {
354 const inf_f128 = math.inf(f128);
351355 try test__powitf2(0, 0, 1);
352356 try test__powitf2(1, 0, 1);
353357 try test__powitf2(1.5, 0, 1);
354358 try test__powitf2(2, 0, 1);
355 try test__powitf2(math.inf_f128, 0, 1);
359 try test__powitf2(inf_f128, 0, 1);
356360
357361 try test__powitf2(-0.0, 0, 1);
358362 try test__powitf2(-1, 0, 1);
359363 try test__powitf2(-1.5, 0, 1);
360364 try test__powitf2(-2, 0, 1);
361 try test__powitf2(-math.inf_f128, 0, 1);
365 try test__powitf2(-inf_f128, 0, 1);
362366
363367 try test__powitf2(0, 1, 0);
364368 try test__powitf2(0, 2, 0);
......@@ -381,35 +385,35 @@ test "powitf2" {
381385 try test__powitf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
382386 try test__powitf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
383387
384 try test__powitf2(math.inf_f128, 1, math.inf_f128);
385 try test__powitf2(math.inf_f128, 2, math.inf_f128);
386 try test__powitf2(math.inf_f128, 3, math.inf_f128);
387 try test__powitf2(math.inf_f128, 4, math.inf_f128);
388 try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f128);
389 try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f128);
390
391 try test__powitf2(-math.inf_f128, 1, -math.inf_f128);
392 try test__powitf2(-math.inf_f128, 2, math.inf_f128);
393 try test__powitf2(-math.inf_f128, 3, -math.inf_f128);
394 try test__powitf2(-math.inf_f128, 4, math.inf_f128);
395 try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f128);
396 try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f128);
397
398 try test__powitf2(0, -1, math.inf_f128);
399 try test__powitf2(0, -2, math.inf_f128);
400 try test__powitf2(0, -3, math.inf_f128);
401 try test__powitf2(0, -4, math.inf_f128);
402 try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f128);
403 try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f128);
404 try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f128);
405
406 try test__powitf2(-0.0, -1, -math.inf_f128);
407 try test__powitf2(-0.0, -2, math.inf_f128);
408 try test__powitf2(-0.0, -3, -math.inf_f128);
409 try test__powitf2(-0.0, -4, math.inf_f128);
410 try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f128);
411 try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f128);
412 try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f128);
388 try test__powitf2(inf_f128, 1, inf_f128);
389 try test__powitf2(inf_f128, 2, inf_f128);
390 try test__powitf2(inf_f128, 3, inf_f128);
391 try test__powitf2(inf_f128, 4, inf_f128);
392 try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f128);
393 try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f128);
394
395 try test__powitf2(-inf_f128, 1, -inf_f128);
396 try test__powitf2(-inf_f128, 2, inf_f128);
397 try test__powitf2(-inf_f128, 3, -inf_f128);
398 try test__powitf2(-inf_f128, 4, inf_f128);
399 try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f128);
400 try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f128);
401
402 try test__powitf2(0, -1, inf_f128);
403 try test__powitf2(0, -2, inf_f128);
404 try test__powitf2(0, -3, inf_f128);
405 try test__powitf2(0, -4, inf_f128);
406 try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f128);
407 try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f128);
408 try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f128);
409
410 try test__powitf2(-0.0, -1, -inf_f128);
411 try test__powitf2(-0.0, -2, inf_f128);
412 try test__powitf2(-0.0, -3, -inf_f128);
413 try test__powitf2(-0.0, -4, inf_f128);
414 try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f128);
415 try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f128);
416 try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f128);
413417
414418 try test__powitf2(1, -1, 1);
415419 try test__powitf2(1, -2, 1);
......@@ -419,21 +423,21 @@ test "powitf2" {
419423 try test__powitf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
420424 try test__powitf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
421425
422 try test__powitf2(math.inf_f128, -1, 0);
423 try test__powitf2(math.inf_f128, -2, 0);
424 try test__powitf2(math.inf_f128, -3, 0);
425 try test__powitf2(math.inf_f128, -4, 0);
426 try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
427 try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000001)), 0);
428 try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
429
430 try test__powitf2(-math.inf_f128, -1, -0.0);
431 try test__powitf2(-math.inf_f128, -2, 0);
432 try test__powitf2(-math.inf_f128, -3, -0.0);
433 try test__powitf2(-math.inf_f128, -4, 0);
434 try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
435 try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
436 try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
426 try test__powitf2(inf_f128, -1, 0);
427 try test__powitf2(inf_f128, -2, 0);
428 try test__powitf2(inf_f128, -3, 0);
429 try test__powitf2(inf_f128, -4, 0);
430 try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
431 try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000001)), 0);
432 try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
433
434 try test__powitf2(-inf_f128, -1, -0.0);
435 try test__powitf2(-inf_f128, -2, 0);
436 try test__powitf2(-inf_f128, -3, -0.0);
437 try test__powitf2(-inf_f128, -4, 0);
438 try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
439 try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
440 try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
437441
438442 try test__powitf2(2, 10, 1024.0);
439443 try test__powitf2(-2, 10, 1024.0);
......@@ -452,17 +456,18 @@ test "powitf2" {
452456}
453457
454458test "powixf2" {
459 const inf_f80 = math.inf(f80);
455460 try test__powixf2(0, 0, 1);
456461 try test__powixf2(1, 0, 1);
457462 try test__powixf2(1.5, 0, 1);
458463 try test__powixf2(2, 0, 1);
459 try test__powixf2(math.inf_f80, 0, 1);
464 try test__powixf2(inf_f80, 0, 1);
460465
461466 try test__powixf2(-0.0, 0, 1);
462467 try test__powixf2(-1, 0, 1);
463468 try test__powixf2(-1.5, 0, 1);
464469 try test__powixf2(-2, 0, 1);
465 try test__powixf2(-math.inf_f80, 0, 1);
470 try test__powixf2(-inf_f80, 0, 1);
466471
467472 try test__powixf2(0, 1, 0);
468473 try test__powixf2(0, 2, 0);
......@@ -485,35 +490,35 @@ test "powixf2" {
485490 try test__powixf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
486491 try test__powixf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
487492
488 try test__powixf2(math.inf_f80, 1, math.inf_f80);
489 try test__powixf2(math.inf_f80, 2, math.inf_f80);
490 try test__powixf2(math.inf_f80, 3, math.inf_f80);
491 try test__powixf2(math.inf_f80, 4, math.inf_f80);
492 try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f80);
493 try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f80);
494
495 try test__powixf2(-math.inf_f80, 1, -math.inf_f80);
496 try test__powixf2(-math.inf_f80, 2, math.inf_f80);
497 try test__powixf2(-math.inf_f80, 3, -math.inf_f80);
498 try test__powixf2(-math.inf_f80, 4, math.inf_f80);
499 try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f80);
500 try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f80);
501
502 try test__powixf2(0, -1, math.inf_f80);
503 try test__powixf2(0, -2, math.inf_f80);
504 try test__powixf2(0, -3, math.inf_f80);
505 try test__powixf2(0, -4, math.inf_f80);
506 try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f80);
507 try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f80);
508 try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f80);
509
510 try test__powixf2(-0.0, -1, -math.inf_f80);
511 try test__powixf2(-0.0, -2, math.inf_f80);
512 try test__powixf2(-0.0, -3, -math.inf_f80);
513 try test__powixf2(-0.0, -4, math.inf_f80);
514 try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f80);
515 try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f80);
516 try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f80);
493 try test__powixf2(inf_f80, 1, inf_f80);
494 try test__powixf2(inf_f80, 2, inf_f80);
495 try test__powixf2(inf_f80, 3, inf_f80);
496 try test__powixf2(inf_f80, 4, inf_f80);
497 try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f80);
498 try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f80);
499
500 try test__powixf2(-inf_f80, 1, -inf_f80);
501 try test__powixf2(-inf_f80, 2, inf_f80);
502 try test__powixf2(-inf_f80, 3, -inf_f80);
503 try test__powixf2(-inf_f80, 4, inf_f80);
504 try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f80);
505 try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f80);
506
507 try test__powixf2(0, -1, inf_f80);
508 try test__powixf2(0, -2, inf_f80);
509 try test__powixf2(0, -3, inf_f80);
510 try test__powixf2(0, -4, inf_f80);
511 try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f80);
512 try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f80);
513 try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f80);
514
515 try test__powixf2(-0.0, -1, -inf_f80);
516 try test__powixf2(-0.0, -2, inf_f80);
517 try test__powixf2(-0.0, -3, -inf_f80);
518 try test__powixf2(-0.0, -4, inf_f80);
519 try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f80);
520 try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f80);
521 try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f80);
517522
518523 try test__powixf2(1, -1, 1);
519524 try test__powixf2(1, -2, 1);
......@@ -523,21 +528,21 @@ test "powixf2" {
523528 try test__powixf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
524529 try test__powixf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
525530
526 try test__powixf2(math.inf_f80, -1, 0);
527 try test__powixf2(math.inf_f80, -2, 0);
528 try test__powixf2(math.inf_f80, -3, 0);
529 try test__powixf2(math.inf_f80, -4, 0);
530 try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
531 try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000001)), 0);
532 try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
533
534 try test__powixf2(-math.inf_f80, -1, -0.0);
535 try test__powixf2(-math.inf_f80, -2, 0);
536 try test__powixf2(-math.inf_f80, -3, -0.0);
537 try test__powixf2(-math.inf_f80, -4, 0);
538 try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
539 try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
540 try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
531 try test__powixf2(inf_f80, -1, 0);
532 try test__powixf2(inf_f80, -2, 0);
533 try test__powixf2(inf_f80, -3, 0);
534 try test__powixf2(inf_f80, -4, 0);
535 try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
536 try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000001)), 0);
537 try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
538
539 try test__powixf2(-inf_f80, -1, -0.0);
540 try test__powixf2(-inf_f80, -2, 0);
541 try test__powixf2(-inf_f80, -3, -0.0);
542 try test__powixf2(-inf_f80, -4, 0);
543 try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
544 try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
545 try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
541546
542547 try test__powixf2(2, 10, 1024.0);
543548 try test__powixf2(-2, 10, 1024.0);
lib/std/math.zig+121-38
......@@ -48,43 +48,41 @@ pub const floatMax = @import("math/float.zig").floatMax;
4848pub const floatEps = @import("math/float.zig").floatEps;
4949pub const inf = @import("math/float.zig").inf;
5050
51// TODO Replace with @compileError("deprecated for foobar") after 0.10.0 is released.
52pub const f16_true_min: comptime_float = floatTrueMin(f16); // prev: 0.000000059604644775390625
53pub const f32_true_min: comptime_float = floatTrueMin(f32); // prev: 1.40129846432481707092e-45
54pub const f64_true_min: comptime_float = floatTrueMin(f64); // prev: 4.94065645841246544177e-324
55pub const f80_true_min = floatTrueMin(f80); // prev: make_f80(.{ .fraction = 1, .exp = 0 })
56pub const f128_true_min = floatTrueMin(f128); // prev: @bitCast(f128, @as(u128, 0x00000000000000000000000000000001))
57pub const f16_min: comptime_float = floatMin(f16); // prev: 0.00006103515625
58pub const f32_min: comptime_float = floatMin(f32); // prev: 1.17549435082228750797e-38
59pub const f64_min: comptime_float = floatMin(f64); // prev: 2.2250738585072014e-308
60pub const f80_min = floatMin(f80); // prev: make_f80(.{ .fraction = 0x8000000000000000, .exp = 1 })
61pub const f128_min = floatMin(f128); // prev: @bitCast(f128, @as(u128, 0x00010000000000000000000000000000))
62pub const f16_max: comptime_float = floatMax(f16); // prev: 65504
63pub const f32_max: comptime_float = floatMax(f32); // prev: 3.40282346638528859812e+38
64pub const f64_max: comptime_float = floatMax(f64); // prev: 1.79769313486231570815e+308
65pub const f80_max = floatMax(f80); // prev: make_f80(.{ .fraction = 0xFFFFFFFFFFFFFFFF, .exp = 0x7FFE })
66pub const f128_max = floatMax(f128); // prev: @bitCast(f128, @as(u128, 0x7FFEFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
67pub const f16_epsilon: comptime_float = floatEps(f16); // prev: 0.0009765625
68pub const f32_epsilon: comptime_float = floatEps(f32); // prev: 1.1920928955078125e-07
69pub const f64_epsilon: comptime_float = floatEps(f64); // prev: 2.22044604925031308085e-16
70pub const f80_epsilon = floatEps(f80); // prev: make_f80(.{ .fraction = 0x8000000000000000, .exp = 0x3FC0 })
71pub const f128_epsilon = floatEps(f128); // prev: @bitCast(f128, @as(u128, 0x3F8F0000000000000000000000000000))
72pub const f16_toint: comptime_float = 1.0 / f16_epsilon; // same as before
73pub const f32_toint: comptime_float = 1.0 / f32_epsilon; // same as before
74pub const f64_toint: comptime_float = 1.0 / f64_epsilon; // same as before
75pub const f80_toint = 1.0 / f80_epsilon; // same as before
76pub const f128_toint = 1.0 / f128_epsilon; // same as before
77pub const inf_u16 = @bitCast(u16, inf_f16); // prev: @as(u16, 0x7C00)
78pub const inf_f16 = inf(f16); // prev: @bitCast(f16, inf_u16)
79pub const inf_u32 = @bitCast(u32, inf_f32); // prev: @as(u32, 0x7F800000)
80pub const inf_f32 = inf(f32); // prev: @bitCast(f32, inf_u32)
81pub const inf_u64 = @bitCast(u64, inf_f64); // prev: @as(u64, 0x7FF << 52)
82pub const inf_f64 = inf(f64); // prev: @bitCast(f64, inf_u64)
83pub const inf_f80 = inf(f80); // prev: make_f80(F80{ .fraction = 0x8000000000000000, .exp = 0x7fff })
84pub const inf_u128 = @bitCast(u128, inf_f128); // prev: @as(u128, 0x7fff0000000000000000000000000000)
85pub const inf_f128 = inf(f128); // prev: @bitCast(f128, inf_u128)
86pub const epsilon = floatEps;
87// End of "soft deprecated" section
51pub const f16_true_min = @compileError("Deprecated: use `floatTrueMin(f16)` instead");
52pub const f32_true_min = @compileError("Deprecated: use `floatTrueMin(f32)` instead");
53pub const f64_true_min = @compileError("Deprecated: use `floatTrueMin(f64)` instead");
54pub const f80_true_min = @compileError("Deprecated: use `floatTrueMin(f80)` instead");
55pub const f128_true_min = @compileError("Deprecated: use `floatTrueMin(f128)` instead");
56pub const f16_min = @compileError("Deprecated: use `floatMin(f16)` instead");
57pub const f32_min = @compileError("Deprecated: use `floatMin(f32)` instead");
58pub const f64_min = @compileError("Deprecated: use `floatMin(f64)` instead");
59pub const f80_min = @compileError("Deprecated: use `floatMin(f80)` instead");
60pub const f128_min = @compileError("Deprecated: use `floatMin(f128)` instead");
61pub const f16_max = @compileError("Deprecated: use `floatMax(f16)` instead");
62pub const f32_max = @compileError("Deprecated: use `floatMax(f32)` instead");
63pub const f64_max = @compileError("Deprecated: use `floatMax(f64)` instead");
64pub const f80_max = @compileError("Deprecated: use `floatMax(f80)` instead");
65pub const f128_max = @compileError("Deprecated: use `floatMax(f128)` instead");
66pub const f16_epsilon = @compileError("Deprecated: use `floatEps(f16)` instead");
67pub const f32_epsilon = @compileError("Deprecated: use `floatEps(f32)` instead");
68pub const f64_epsilon = @compileError("Deprecated: use `floatEps(f64)` instead");
69pub const f80_epsilon = @compileError("Deprecated: use `floatEps(f80)` instead");
70pub const f128_epsilon = @compileError("Deprecated: use `floatEps(f128)` instead");
71pub const f16_toint = @compileError("Deprecated: use `1.0 / floatEps(f16)` instead");
72pub const f32_toint = @compileError("Deprecated: use `1.0 / floatEps(f32)` instead");
73pub const f64_toint = @compileError("Deprecated: use `1.0 / floatEps(f64)` instead");
74pub const f80_toint = @compileError("Deprecated: use `1.0 / floatEps(f80)` instead");
75pub const f128_toint = @compileError("Deprecated: use `1.0 / floatEps(f128)` instead");
76pub const inf_u16 = @compileError("Deprecated: use `@bitCast(u16, inf(f16))` instead");
77pub const inf_f16 = @compileError("Deprecated: use `inf(f16)` instead");
78pub const inf_u32 = @compileError("Deprecated: use `@bitCast(u32, inf(f32))` instead");
79pub const inf_f32 = @compileError("Deprecated: use `inf(f32)` instead");
80pub const inf_u64 = @compileError("Deprecated: use `@bitCast(u64, inf(f64))` instead");
81pub const inf_f64 = @compileError("Deprecated: use `inf(f64)` instead");
82pub const inf_f80 = @compileError("Deprecated: use `inf(f80)` instead");
83pub const inf_u128 = @compileError("Deprecated: use `@bitCast(u128, inf(f128))` instead");
84pub const inf_f128 = @compileError("Deprecated: use `inf(f128)` instead");
85pub const epsilon = @compileError("Deprecated: use `floatEps` instead");
8886
8987pub const nan_u16 = @as(u16, 0x7C01);
9088pub const nan_f16 = @bitCast(f16, nan_u16);
......@@ -329,7 +327,92 @@ pub const Complex = complex.Complex;
329327pub const big = @import("math/big.zig");
330328
331329test {
332 std.testing.refAllDecls(@This());
330 _ = floatExponentBits;
331 _ = floatMantissaBits;
332 _ = floatFractionalBits;
333 _ = floatExponentMin;
334 _ = floatExponentMax;
335 _ = floatTrueMin;
336 _ = floatMin;
337 _ = floatMax;
338 _ = floatEps;
339 _ = inf;
340
341 _ = nan_u16;
342 _ = nan_f16;
343
344 _ = qnan_u16;
345 _ = qnan_f16;
346
347 _ = nan_u32;
348 _ = nan_f32;
349
350 _ = qnan_u32;
351 _ = qnan_f32;
352
353 _ = nan_u64;
354 _ = nan_f64;
355
356 _ = qnan_u64;
357 _ = qnan_f64;
358
359 _ = nan_f80;
360 _ = qnan_f80;
361
362 _ = nan_u128;
363 _ = nan_f128;
364
365 _ = qnan_u128;
366 _ = qnan_f128;
367
368 _ = nan;
369 _ = snan;
370
371 _ = isNan;
372 _ = isSignalNan;
373 _ = frexp;
374 _ = Frexp;
375 _ = modf;
376 _ = modf32_result;
377 _ = modf64_result;
378 _ = copysign;
379 _ = isFinite;
380 _ = isInf;
381 _ = isPositiveInf;
382 _ = isNegativeInf;
383 _ = isNormal;
384 _ = signbit;
385 _ = scalbn;
386 _ = ldexp;
387 _ = pow;
388 _ = powi;
389 _ = sqrt;
390 _ = cbrt;
391 _ = acos;
392 _ = asin;
393 _ = atan;
394 _ = atan2;
395 _ = hypot;
396 _ = expm1;
397 _ = ilogb;
398 _ = ln;
399 _ = log;
400 _ = log2;
401 _ = log10;
402 _ = log10_int;
403 _ = log1p;
404 _ = asinh;
405 _ = acosh;
406 _ = atanh;
407 _ = sinh;
408 _ = cosh;
409 _ = tanh;
410 _ = gcd;
411
412 _ = complex;
413 _ = Complex;
414
415 _ = big;
333416}
334417
335418/// Given two types, returns the smallest one which is capable of holding the
lib/std/rand.zig+1-1
......@@ -410,7 +410,7 @@ pub const Random = struct {
410410 r.uintLessThan(T, sum)
411411 else if (comptime std.meta.trait.isFloat(T))
412412 // take care that imprecision doesn't lead to a value slightly greater than sum
413 std.math.min(r.float(T) * sum, sum - std.math.epsilon(T))
413 std.math.min(r.float(T) * sum, sum - std.math.floatEps(T))
414414 else
415415 @compileError("weightedIndex does not support proportions of type " ++ @typeName(T));
416416
lib/std/testing.zig+1-1
......@@ -263,7 +263,7 @@ pub fn expectApproxEqRel(expected: anytype, actual: @TypeOf(expected), tolerance
263263
264264test "expectApproxEqRel" {
265265 inline for ([_]type{ f16, f32, f64, f128 }) |T| {
266 const eps_value = comptime math.epsilon(T);
266 const eps_value = comptime math.floatEps(T);
267267 const sqrt_eps_value = comptime @sqrt(eps_value);
268268
269269 const pos_x: T = 12.0;
test/behavior/pointers.zig+3-3
......@@ -357,9 +357,9 @@ test "pointer sentinel with +inf" {
357357
358358 const S = struct {
359359 fn doTheTest() !void {
360 const inf = std.math.inf_f32;
361 var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
362 try expect(ptr[4] == inf); // TODO this should be comptime try expect, see #3731
360 const inf_f32 = comptime std.math.inf(f32);
361 var ptr: [*:inf_f32]const f32 = &[_:inf_f32]f32{ 1.1, 2.2, 3.3, 4.4 };
362 try expect(ptr[4] == inf_f32); // TODO this should be comptime try expect, see #3731
363363 }
364364 };
365365 try S.doTheTest();