mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-14 02:06:16 +01:00
Our implementation did the classic add-sub rounding trick `(y = x +/- C =+ C - x)` with `C = 1 / eps(T) = 2^(mantissa - 1)`. This approach only works for values whose magnitude is below the rounding capacity of the constant. For a 64-bit mantissa (like f80 has), `C = 2^63` only rounds for `|x| < 2^63`. Before we allowed this to be ran on `e < bias + 64` aka `|x| < 2^64`. And because it isn't large enough, we lose a bit to rounding. For reference, the musl implementation does the same thing, using `mantissa - 1`: https://git.musl-libc.org/cgit/musl/tree/src/math/ceill.c#n18 where `LDBL_MANT_DIG` is 64 for `long double` on x86. This commit also combines the floor and ceil implementations into one generic one. |
||
|---|---|---|
| .. | ||
| build-web | ||
| c | ||
| compiler | ||
| compiler_rt | ||
| docs | ||
| include | ||
| init | ||
| libc | ||
| libcxx | ||
| libcxxabi | ||
| libtsan | ||
| libunwind | ||
| std | ||
| c.zig | ||
| compiler_rt.zig | ||
| fuzzer.zig | ||
| ubsan_rt.zig | ||
| zig.h | ||