authorgravatar for lewis.gaul@gmail.comLewis Gaul <lewis.gaul@gmail.com> 2024-05-25 23:05:20+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-17 05:04:59+02:00
log03dfd2ecc37cc99b15d4ce3ff19147230ddc8fd4
tree884eb9f9b59110715ca4618393ee2369dcec2cb2
parent7abb170f59ed959c4004ec37258c8905903f36b1

Make sure to test the sign of the zero results


7 files changed, 18 insertions(+), 18 deletions(-)

lib/compiler_rt/exp.zig+2-2
...@@ -218,7 +218,7 @@ test "expf() special" {...@@ -218,7 +218,7 @@ test "expf() special" {
218 try expectEqual(expf(1.0), math.e);218 try expectEqual(expf(1.0), math.e);
219 try expectEqual(expf(math.ln2), 2.0);219 try expectEqual(expf(math.ln2), 2.0);
220 try expectEqual(expf(math.inf(f32)), math.inf(f32));220 try expectEqual(expf(math.inf(f32)), math.inf(f32));
221 try expectEqual(expf(-math.inf(f32)), 0.0);221 try expect(math.isPositiveZero(expf(-math.inf(f32))));
222 try expect(math.isNan(expf(math.nan(f32))));222 try expect(math.isNan(expf(math.nan(f32))));
223 try expect(math.isNan(expf(math.snan(f32))));223 try expect(math.isNan(expf(math.snan(f32))));
224}224}
...@@ -268,7 +268,7 @@ test "exp() special" {...@@ -268,7 +268,7 @@ test "exp() special" {
268 // try expectEqual(exp(1.0), math.e);268 // try expectEqual(exp(1.0), math.e);
269 try expectEqual(exp(math.ln2), 2.0);269 try expectEqual(exp(math.ln2), 2.0);
270 try expectEqual(exp(math.inf(f64)), math.inf(f64));270 try expectEqual(exp(math.inf(f64)), math.inf(f64));
271 try expectEqual(exp(-math.inf(f64)), 0.0);271 try expect(math.isPositiveZero(exp(-math.inf(f64))));
272 try expect(math.isNan(exp(math.nan(f64))));272 try expect(math.isNan(exp(math.nan(f64))));
273 try expect(math.isNan(exp(math.snan(f64))));273 try expect(math.isNan(exp(math.snan(f64))));
274}274}
lib/compiler_rt/exp2.zig+2-2
...@@ -464,7 +464,7 @@ test "exp2f() special" {...@@ -464,7 +464,7 @@ test "exp2f() special" {
464 try expectEqual(exp2f(1.0), 2.0);464 try expectEqual(exp2f(1.0), 2.0);
465 try expectEqual(exp2f(-1.0), 0.5);465 try expectEqual(exp2f(-1.0), 0.5);
466 try expectEqual(exp2f(math.inf(f32)), math.inf(f32));466 try expectEqual(exp2f(math.inf(f32)), math.inf(f32));
467 try expectEqual(exp2f(-math.inf(f32)), 0.0);467 try expect(math.isPositiveZero(exp2f(-math.inf(f32))));
468 try expect(math.isNan(exp2f(math.nan(f32))));468 try expect(math.isNan(exp2f(math.nan(f32))));
469 try expect(math.isNan(exp2f(math.snan(f32))));469 try expect(math.isNan(exp2f(math.snan(f32))));
470}470}
...@@ -502,7 +502,7 @@ test "exp2() special" {...@@ -502,7 +502,7 @@ test "exp2() special" {
502 try expectEqual(exp2(1.0), 2.0);502 try expectEqual(exp2(1.0), 2.0);
503 try expectEqual(exp2(-1.0), 0.5);503 try expectEqual(exp2(-1.0), 0.5);
504 try expectEqual(exp2(math.inf(f64)), math.inf(f64));504 try expectEqual(exp2(math.inf(f64)), math.inf(f64));
505 try expectEqual(exp2(-math.inf(f64)), 0.0);505 try expect(math.isPositiveZero(exp2(-math.inf(f64))));
506 try expect(math.isNan(exp2(math.nan(f64))));506 try expect(math.isNan(exp2(math.nan(f64))));
507 try expect(math.isNan(exp2(math.snan(f64))));507 try expect(math.isNan(exp2(math.snan(f64))));
508}508}
lib/compiler_rt/log.zig+2-2
...@@ -163,7 +163,7 @@ pub fn logl(x: c_longdouble) callconv(.c) c_longdouble {...@@ -163,7 +163,7 @@ pub fn logl(x: c_longdouble) callconv(.c) c_longdouble {
163test "logf() special" {163test "logf() special" {
164 try expectEqual(logf(0.0), -math.inf(f32));164 try expectEqual(logf(0.0), -math.inf(f32));
165 try expectEqual(logf(-0.0), -math.inf(f32));165 try expectEqual(logf(-0.0), -math.inf(f32));
166 try expectEqual(logf(1.0), 0.0);166 try expect(math.isPositiveZero(logf(1.0)));
167 try expectEqual(logf(math.e), 1.0);167 try expectEqual(logf(math.e), 1.0);
168 try expectEqual(logf(math.inf(f32)), math.inf(f32));168 try expectEqual(logf(math.inf(f32)), math.inf(f32));
169 try expect(math.isNan(logf(-1.0)));169 try expect(math.isNan(logf(-1.0)));
...@@ -198,7 +198,7 @@ test "logf() boundary" {...@@ -198,7 +198,7 @@ test "logf() boundary" {
198test "log() special" {198test "log() special" {
199 try expectEqual(log(0.0), -math.inf(f64));199 try expectEqual(log(0.0), -math.inf(f64));
200 try expectEqual(log(-0.0), -math.inf(f64));200 try expectEqual(log(-0.0), -math.inf(f64));
201 try expectEqual(log(1.0), 0.0);201 try expect(math.isPositiveZero(log(1.0)));
202 try expectEqual(log(math.e), 1.0);202 try expectEqual(log(math.e), 1.0);
203 try expectEqual(log(math.inf(f64)), math.inf(f64));203 try expectEqual(log(math.inf(f64)), math.inf(f64));
204 try expect(math.isNan(log(-1.0)));204 try expect(math.isNan(log(-1.0)));
lib/compiler_rt/log10.zig+2-2
...@@ -191,7 +191,7 @@ pub fn log10l(x: c_longdouble) callconv(.c) c_longdouble {...@@ -191,7 +191,7 @@ pub fn log10l(x: c_longdouble) callconv(.c) c_longdouble {
191test "log10f() special" {191test "log10f() special" {
192 try expectEqual(log10f(0.0), -math.inf(f32));192 try expectEqual(log10f(0.0), -math.inf(f32));
193 try expectEqual(log10f(-0.0), -math.inf(f32));193 try expectEqual(log10f(-0.0), -math.inf(f32));
194 try expectEqual(log10f(1.0), 0.0);194 try expect(math.isPositiveZero(log10f(1.0)));
195 try expectEqual(log10f(10.0), 1.0);195 try expectEqual(log10f(10.0), 1.0);
196 try expectEqual(log10f(0.1), -1.0);196 try expectEqual(log10f(0.1), -1.0);
197 try expectEqual(log10f(math.inf(f32)), math.inf(f32));197 try expectEqual(log10f(math.inf(f32)), math.inf(f32));
...@@ -227,7 +227,7 @@ test "log10f() boundary" {...@@ -227,7 +227,7 @@ test "log10f() boundary" {
227test "log10() special" {227test "log10() special" {
228 try expectEqual(log10(0.0), -math.inf(f64));228 try expectEqual(log10(0.0), -math.inf(f64));
229 try expectEqual(log10(-0.0), -math.inf(f64));229 try expectEqual(log10(-0.0), -math.inf(f64));
230 try expectEqual(log10(1.0), 0.0);230 try expect(math.isPositiveZero(log10(1.0)));
231 try expectEqual(log10(10.0), 1.0);231 try expectEqual(log10(10.0), 1.0);
232 try expectEqual(log10(0.1), -1.0);232 try expectEqual(log10(0.1), -1.0);
233 try expectEqual(log10(math.inf(f64)), math.inf(f64));233 try expectEqual(log10(math.inf(f64)), math.inf(f64));
lib/compiler_rt/log2.zig+2-2
...@@ -183,7 +183,7 @@ pub fn log2l(x: c_longdouble) callconv(.c) c_longdouble {...@@ -183,7 +183,7 @@ pub fn log2l(x: c_longdouble) callconv(.c) c_longdouble {
183test "log2f() special" {183test "log2f() special" {
184 try expectEqual(log2f(0.0), -math.inf(f32));184 try expectEqual(log2f(0.0), -math.inf(f32));
185 try expectEqual(log2f(-0.0), -math.inf(f32));185 try expectEqual(log2f(-0.0), -math.inf(f32));
186 try expectEqual(log2f(1.0), 0.0);186 try expect(math.isPositiveZero(log2f(1.0)));
187 try expectEqual(log2f(2.0), 1.0);187 try expectEqual(log2f(2.0), 1.0);
188 try expectEqual(log2f(math.inf(f32)), math.inf(f32));188 try expectEqual(log2f(math.inf(f32)), math.inf(f32));
189 try expect(math.isNan(log2f(-1.0)));189 try expect(math.isNan(log2f(-1.0)));
...@@ -219,7 +219,7 @@ test "log2f() boundary" {...@@ -219,7 +219,7 @@ test "log2f() boundary" {
219test "log2() special" {219test "log2() special" {
220 try expectEqual(log2(0.0), -math.inf(f64));220 try expectEqual(log2(0.0), -math.inf(f64));
221 try expectEqual(log2(-0.0), -math.inf(f64));221 try expectEqual(log2(-0.0), -math.inf(f64));
222 try expectEqual(log2(1.0), 0.0);222 try expect(math.isPositiveZero(log2(1.0)));
223 try expectEqual(log2(2.0), 1.0);223 try expectEqual(log2(2.0), 1.0);
224 try expectEqual(log2(math.inf(f64)), math.inf(f64));224 try expectEqual(log2(math.inf(f64)), math.inf(f64));
225 try expect(math.isNan(log2(-1.0)));225 try expect(math.isNan(log2(-1.0)));
lib/std/math/expm1.zig+4-4
...@@ -288,8 +288,8 @@ fn expm1_64(x_: f64) f64 {...@@ -288,8 +288,8 @@ fn expm1_64(x_: f64) f64 {
288}288}
289289
290test "expm1_32() special" {290test "expm1_32() special" {
291 try expectEqual(expm1_32(0.0), 0.0);291 try expect(math.isPositiveZero(expm1_32(0.0)));
292 try expectEqual(expm1_32(-0.0), 0.0);292 try expect(math.isNegativeZero(expm1_32(-0.0)));
293 try expectEqual(expm1_32(math.ln2), 1.0);293 try expectEqual(expm1_32(math.ln2), 1.0);
294 try expectEqual(expm1_32(math.inf(f32)), math.inf(f32));294 try expectEqual(expm1_32(math.inf(f32)), math.inf(f32));
295 try expectEqual(expm1_32(-math.inf(f32)), -1.0);295 try expectEqual(expm1_32(-math.inf(f32)), -1.0);
...@@ -326,8 +326,8 @@ test "expm1_32() boundary" {...@@ -326,8 +326,8 @@ test "expm1_32() boundary" {
326}326}
327327
328test "expm1_64() special" {328test "expm1_64() special" {
329 try expectEqual(expm1_64(0.0), 0.0);329 try expect(math.isPositiveZero(expm1_64(0.0)));
330 try expectEqual(expm1_64(-0.0), 0.0);330 try expect(math.isNegativeZero(expm1_64(-0.0)));
331 try expectEqual(expm1_64(math.ln2), 1.0);331 try expectEqual(expm1_64(math.ln2), 1.0);
332 try expectEqual(expm1_64(math.inf(f64)), math.inf(f64));332 try expectEqual(expm1_64(math.inf(f64)), math.inf(f64));
333 try expectEqual(expm1_64(-math.inf(f64)), -1.0);333 try expectEqual(expm1_64(-math.inf(f64)), -1.0);
lib/std/math/log1p.zig+4-4
...@@ -184,8 +184,8 @@ fn log1p_64(x: f64) f64 {...@@ -184,8 +184,8 @@ fn log1p_64(x: f64) f64 {
184}184}
185185
186test "log1p_32() special" {186test "log1p_32() special" {
187 try expectEqual(log1p_32(0.0), 0.0);187 try expect(math.isPositiveZero(log1p_32(0.0)));
188 try expectEqual(log1p_32(-0.0), 0.0);188 try expect(math.isNegativeZero(log1p_32(-0.0)));
189 try expectEqual(log1p_32(-1.0), -math.inf(f32));189 try expectEqual(log1p_32(-1.0), -math.inf(f32));
190 try expectEqual(log1p_32(1.0), math.ln2);190 try expectEqual(log1p_32(1.0), math.ln2);
191 try expectEqual(log1p_32(math.inf(f32)), math.inf(f32));191 try expectEqual(log1p_32(math.inf(f32)), math.inf(f32));
...@@ -219,8 +219,8 @@ test "log1p_32() boundary" {...@@ -219,8 +219,8 @@ test "log1p_32() boundary" {
219}219}
220220
221test "log1p_64() special" {221test "log1p_64() special" {
222 try expectEqual(log1p_64(0.0), 0.0);222 try expect(math.isPositiveZero(log1p_64(0.0)));
223 try expectEqual(log1p_64(-0.0), 0.0);223 try expect(math.isNegativeZero(log1p_64(-0.0)));
224 try expectEqual(log1p_64(-1.0), -math.inf(f64));224 try expectEqual(log1p_64(-1.0), -math.inf(f64));
225 try expectEqual(log1p_64(1.0), math.ln2);225 try expectEqual(log1p_64(1.0), math.ln2);
226 try expectEqual(log1p_64(math.inf(f64)), math.inf(f64));226 try expectEqual(log1p_64(math.inf(f64)), math.inf(f64));