mirror of
https://github.com/ziglang/zig.git
synced 2026-01-07 14:03:26 +00:00
std: Fix typo in sqrt implementation
The code initializes twice `t` instead of `t1`, leaving the latter uninitialized. The problem manifested itself by corrupting the LSBs of the result in unpredictable ways.
This commit is contained in:
parent
8d94dc625b
commit
44f8ce690d
@ -874,7 +874,7 @@ export fn sqrt(x: f64) f64 {
|
||||
|
||||
r = sign;
|
||||
while (r != 0) {
|
||||
t = s1 +% r;
|
||||
t1 = s1 +% r;
|
||||
t = s0;
|
||||
if (t < ix0 or (t == ix0 and t1 <= ix1)) {
|
||||
s1 = t1 +% r;
|
||||
|
||||
@ -60,6 +60,6 @@ test "bug 920 fixed" {
|
||||
};
|
||||
|
||||
for (NormalDist1.f) |_, i| {
|
||||
std.testing.expect(NormalDist1.f[i] == NormalDist.f[i]);
|
||||
std.testing.expectEqual(NormalDist1.f[i], NormalDist.f[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user