DoxigAlpha

nextAfter

Returns the next representable value after x in the direction of y.

Special cases:

  • If x == y, y is returned.
  • For floats, if either x or y is a NaN, a NaN is returned.
  • For floats, if x == 0.0 and @abs(y) > 0.0, the smallest subnormal number with the sign of y is returned.

Function parameters

Parameters

#
T:type
x:T
y:T

Returns the next representable value after `x` in the direction of `y`.

Functions

#
nextAfter
Returns the next representable value after `x` in the direction of `y`.

Source

Implementation

#
pub fn nextAfter(comptime T: type, x: T, y: T) T {
    return switch (@typeInfo(T)) {
        .int, .comptime_int => nextAfterInt(T, x, y),
        .float => nextAfterFloat(T, x, y),
        else => @compileError("expected int or non-comptime float, found '" ++ @typeName(T) ++ "'"),
    };
}