Standard library / math

math.Nextafter()

Adjacent float64 representable value in direction y; if equal returns y. Expected stdout: '1.0000000000000002\n'.

Formal Syntax & Structure

go syntaxgo
func Nextafter(x, y float64) (r float64)

Parameters & Attributes

NameTypeDescription
xfloat64First input operand (or sole input if unary).
yfloat64Second input operand.

Return Value

(r float64)

Adjacent float64 representable value in direction y; if equal returns y.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math")
func main() {  fmt.Println(math.Nextafter(1, 2))}
Go Reference