zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2cbcf3f38bb32752b449ce72a8d8f978e65008f8 (tree)
parent 60b1cf2a8300591b9b17cc5644bebd358860e7a6
Author: Matthew Murray <matt@matt-is.me>
Date:   Thu, 20 Jun 2019 14:36:34 +0100

Fix absFloat

Diffstat:
Mstd/math.zig | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/std/math.zig b/std/math.zig @@ -482,7 +482,16 @@ fn testAbsInt() void { testing.expect((absInt(i32(10)) catch unreachable) == 10); } -pub const absFloat = @import("fabs.zig").fabs; +pub const absFloat = fabs; + +test "math.absFloat" { + testAbsFloat(); + comptime testAbsFloat(); +} +fn testAbsFloat() void { + testing.expect(absFloat(f32(-10.05)) == 10.05); + testing.expect(absFloat(f32(10.05)) == 10.05); +} pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T { @setRuntimeSafety(false);