zig/test/behavior/muladd.zig
Andrew Kelley 5518a0aff2 freestanding libc: export fmal
libc requires this to use `long double` which is sometimes the same as
f128, sometimes not.

Also for an unknown reason, aarch64 is getting an invalid result for the
`@mulAdd` behavior test for f128. See #9900.
2021-10-05 16:56:46 -07:00

35 lines
809 B
Zig

const expect = @import("std").testing.expect;
test "@mulAdd" {
comptime try testMulAdd();
try testMulAdd();
}
fn testMulAdd() !void {
{
var a: f16 = 5.5;
var b: f16 = 2.5;
var c: f16 = 6.25;
try expect(@mulAdd(f16, a, b, c) == 20);
}
{
var a: f32 = 5.5;
var b: f32 = 2.5;
var c: f32 = 6.25;
try expect(@mulAdd(f32, a, b, c) == 20);
}
{
var a: f64 = 5.5;
var b: f64 = 2.5;
var c: f64 = 6.25;
try expect(@mulAdd(f64, a, b, c) == 20);
}
// TODO https://github.com/ziglang/zig/issues/9900
if (@import("builtin").cpu.arch != .aarch64) {
var a: f16 = 5.5;
var b: f128 = 2.5;
var c: f128 = 6.25;
try expect(@mulAdd(f128, a, b, c) == 20);
}
}