Standard library / math

math.Round()

Nearest integer-valued float, halfway cases away from zero. Expected stdout: '-3\n'.

Formal Syntax & Structure

go syntaxgo
func Round(x float64) float64

Parameters & Attributes

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

Return Value

float64

Nearest integer-valued float, halfway cases away from zero.

Working Example

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