2017-07-02 6:20 GMT+02:00 Dan Kortschak <dan.kortsc...@adelaide.edu.au>: > Is this expected: > > ``` > package main > > import ( > "fmt" > "strconv" > ) > > func main() { > fmt.Print(strconv.FormatFloat(0.5, 'f', 0, 64)) > } > ``` > > ``` > 0 > ``` > > https://play.golang.org/p/HEyxpGPrX3 > > This is truncating, not rounding.
Formatting 0.51 correctly gives "1", and formatting 1.5 will give "2" as expected. The "round half to even" convention is used. Rémy. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.