zig/lib/std/math
castholm ad6f8e3a59
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.
2023-10-06 14:44:47 -04:00
..
big
complex
acos.zig
acosh.zig
asin.zig
asinh.zig
atan.zig
atan2.zig
atanh.zig
big.zig
cbrt.zig
complex.zig
copysign.zig
cosh.zig
expm1.zig
expo2.zig
float.zig
frexp.zig
gcd.zig
hypot.zig
ilogb.zig
isfinite.zig
isinf.zig
isnan.zig
isnormal.zig
ldexp.zig
log.zig
log1p.zig
log2.zig
log10.zig
log_int.zig
modf.zig
nextafter.zig std.math: add nextAfter (#16894) 2023-10-06 14:44:47 -04:00
pow.zig
powi.zig
scalbn.zig
signbit.zig
sinh.zig
sqrt.zig
tanh.zig