Golang implements rounding

Golang does not have a python-like round() function. Recently, I saw a more ingenious processing method. Record it: +0.5 first, then round down!

func round(x float64)int{
    return int(math.Floor(x + 0.5))
}

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish