RoundToEven in Go

Posted by GoDoc
Public (Editable by Users)

RoundToEven returns the nearest integer, rounding ties to even.

Go
Edit
package main

import (
	"fmt"
	"math"
)

func main() {
	u := math.RoundToEven(11.5)
	fmt.Printf("%.1f\n", u)

	d := math.RoundToEven(12.5)
	fmt.Printf("%.1f\n", d)
}