For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
nextafter
def nextafter[dtype: DType, width: SIMDLength, //](arg0: SIMD[dtype, width], arg1: SIMD[dtype, width]) -> SIMD[dtype, width]
Computes next representable value of arg0 in the direction of arg1.
CPU and GPU targets share one Mojo implementation that walks the IEEE-754
bit pattern directly: the only floating-point operation is the NaN check,
so the result is exact on every target and is unaffected by targets that
flush subnormal arithmetic. Read as a signed integer, the raw bit pattern
is monotone on each half of the real line — increasing with value from
+0 to +NaN, and decreasing from -1 at -NaN to the most negative integer
at -0 — so a single ±1 step of the bit pattern, with the direction
decided by the ordering of arg0 and arg1 and the sign of arg0,
reaches the neighbouring representable value.
Constraints:
The element dtype of the input must be a floating-point type.
Parameters:
- dtype (
DType): Thedtypeof the input and output SIMD vector. - width (
SIMDLength): The width of the input and output SIMD vector.
Args:
- arg0 (
SIMD[dtype, width]): The first input argument. - arg1 (
SIMD[dtype, width]): The second input argument.
Returns:
SIMD[dtype, width]: The nextafter of the inputs.