mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 06:04:46 +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. |
||
|---|---|---|
| .. | ||
| behavior | ||
| c_abi | ||
| cases | ||
| cli/options | ||
| incremental | ||
| link | ||
| src | ||
| standalone | ||
| behavior.zig | ||
| cases.zig | ||
| compile_errors.zig | ||
| error_traces.zig | ||
| gen_h.zig | ||
| libc.zig | ||
| llvm_ir.zig | ||
| llvm_targets.zig | ||
| stack_traces.zig | ||
| tests.zig | ||