aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorcastholm <carl@astholm.se>2023-10-06 20:44:47 +0200
committerGitHub <noreply@github.com>2023-10-06 14:44:47 -0400
commitad6f8e3a5955df4d26478bc284919f4e5c8a6913 (patch)
tree3877a9c1b0b2d5b5f198da70fd83cb9412882127 /src/codegen/c.zig
parente6590fea19e3eab94b35bfd3c36e29b53cefcaaf (diff)
downloadzig-ad6f8e3a5955df4d26478bc284919f4e5c8a6913.tar.gz
zig-ad6f8e3a5955df4d26478bc284919f4e5c8a6913.zip
std.math: add nextAfter (#16894)
`nextAfter()` returns the next representable value after `x` in the direction of `y` and is a standard math library function ([C++](https://en.cppreference.com/w/cpp/numeric/math/nextafter), [Java](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextAfter-double-double-)). It is primarily useful for bitwise incrementing/decrementing floats. This implementation supports runtime integers, runtime floats and `comptime_int`. `comptime_float` is not supported because NaNs/infinities are intentionally difficult to obtain and because I'm not sure if the fact that it's backed by `f128` is supposed to be an implementation detail. Either way, the user could just call the function with the floating-point type whose behavior they want at comptime and then cast the result to `comptime_float`. The float implementation was ported from mingw-w64 with some slight changes made possible because the Zig standard library doesn't care about raising FP exceptions. The number of test cases may seem excessive but they should cover every normal and edge case for every float type and are especially important for verifying that `f80` works.
Diffstat (limited to 'src/codegen/c.zig')
0 files changed, 0 insertions, 0 deletions