Math Functions

math.nextafter()

Move from x toward y by the requested number of representable floating-point steps. The keyword steps was added in 3.12; zero steps preserve x.

Formal Syntax & Structure

python syntaxpython
math.nextafter(x, y, /, *, steps=1)

Parameters & Attributes

NameTypeDescription
xreal numberInput real value.
yreal numberSecond real value.
stepsintNonnegative number of representable steps toward y.

Return Value

float

Floating-point result; finite precision and domain restrictions apply.

Working Example

Example Snippetpython
import mathprint(math.nextafter(1.0, 2.0))
Python Reference