authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-08-03 20:53:56-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-08-03 21:04:04-04:00
log97ced1272df0236a01a72deaaf55e895f2bf62b0
treefb36416ab1472743f7e48e75ecbfa1357641652b
parent4b726207b8eb5a8a0605f3cc164ff0364733c31b

std.math.float: evaluate some constants at comptime

QEMU can mistranslate this code, but since it can be evaluated at comptime anyway, force comptime eval as both a workaround for the mistranslation and because it is a desirable change anyway.

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/math/float.zig+3-3
......@@ -112,17 +112,17 @@ pub fn FloatRepr(comptime Float: type) type {
112112 /// This currently truncates denormal values, which needs to be fixed before this can be used to
113113 /// produce a rounded value.
114114 pub fn reconstruct(normalized: Normalized, sign: std.math.Sign) Float {
115 if (normalized.exponent > BiasedExponent.max_normal.unbias()) return @bitCast(Repr{
115 if (normalized.exponent > comptime BiasedExponent.max_normal.unbias()) return @bitCast(Repr{
116116 .mantissa = 0,
117117 .exponent = .infinite,
118118 .sign = sign,
119119 });
120120 const mantissa = @as(Mantissa, 1 << fractional_bits) | normalized.fraction;
121 if (normalized.exponent < BiasedExponent.min_normal.unbias()) return @bitCast(Repr{
121 if (normalized.exponent < comptime BiasedExponent.min_normal.unbias()) return @bitCast(Repr{
122122 .mantissa = @truncate(std.math.shr(
123123 Mantissa,
124124 mantissa,
125 BiasedExponent.min_normal.unbias() - normalized.exponent,
125 (comptime BiasedExponent.min_normal.unbias()) - normalized.exponent,
126126 )),
127127 .exponent = .denormal,
128128 .sign = sign,