mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Fix edge case in addXf3
The operands may be zero, use the wrapping operators and avoid a spurious integer-overflow error.
This commit is contained in:
parent
60242e96df
commit
939ec878a0
@ -78,8 +78,8 @@ fn addXf3(comptime T: type, a: T, b: T) T {
|
||||
const infRep = @bitCast(Z, std.math.inf(T));
|
||||
|
||||
// Detect if a or b is zero, infinity, or NaN.
|
||||
if (aAbs - Z(1) >= infRep - Z(1) or
|
||||
bAbs - Z(1) >= infRep - Z(1))
|
||||
if (aAbs -% Z(1) >= infRep - Z(1) or
|
||||
bAbs -% Z(1) >= infRep - Z(1))
|
||||
{
|
||||
// NaN + anything = qNaN
|
||||
if (aAbs > infRep) return @bitCast(T, @bitCast(Z, a) | quietBit);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user