Standard library / math

math.RoundToEven()

Nearest integer-valued float, halfway cases toward even integer. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func RoundToEven(x float64) float64

Parameters & Attributes

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

Return Value

float64

Nearest integer-valued float, halfway cases toward even integer.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math")
func main() {  fmt.Println(math.RoundToEven(2.5))}
Go Reference