From 5fbda2c579f584c770eadc0e236ed0933be739a8 Mon Sep 17 00:00:00 2001 From: Marc Tiehuis Date: Tue, 3 May 2022 17:14:01 +1200 Subject: [PATCH] temporary fix for stage2/stage1 f128 rounding discrepency This is only to get tests running again. The root issue should be fixed in stage1 so rounding is consistent between stages. --- lib/std/fmt.zig | 1 - test/behavior/math.zig | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 96ed842154d4ee8782da76b51bcc90d4f25cb2b1..64351088f5e7e598ceb62fda9dd0b216f0409de3 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -1842,7 +1842,6 @@ pub const ParseFloatError = @import("fmt/parse_float.zig").ParseFloatError; test { _ = parseFloat; - _ = parseHexFloat; } pub fn charToDigit(c: u8, radix: u8) (error{InvalidCharacter}!u8) { diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 0479015eee8c920c23043421b91207ba821b9e3c..3997f2db04d40a830a209cb3e403eb3908fc51bd 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -778,8 +778,14 @@ test "quad hex float literal parsing accurate" { try expect(@bitCast(u128, f) == 0x40042eab345678439abcdefea5678234); } { - var f: f128 = 0x1.edcb34a235253948765432134674fp-1; - try expect(@bitCast(u128, f) == 0x3ffeedcb34a235253948765432134674); + // TODO: modify stage1/parse_f128.c to use round-to-even + if (builtin.zig_backend == .stage1) { + var f: f128 = 0x1.edcb34a235253948765432134674fp-1; + try expect(@bitCast(u128, f) == 0x3ffeedcb34a235253948765432134674); // round-down + } else { + var f: f128 = 0x1.edcb34a235253948765432134674fp-1; + try expect(@bitCast(u128, f) == 0x3ffeedcb34a235253948765432134675); // round-to-even + } } { var f: f128 = 0x1.353e45674d89abacc3a2ebf3ff4ffp-50; -- 2.54.0