I've stumbled across an issue with some float64 numbers, where they get rounded up as soon as they are assigned to a variable.
package main import ( "fmt" "strconv" ) func main() { fmt.Println(9999999999999999.0 == 10000000000000000.0) //false f1 := 9999999999999999.0 f2 := 10000000000000000.0 fmt.Println(f1 == f2) //true fmt.Println(f1) //1e+16 fmt.Println(f2) //1e+16 fmt.Println(strconv.FormatFloat(f1, 'f', -1, 64)) //10000000000000000 fmt.Println(strconv.FormatFloat(f2, 'f', -1, 64)) //10000000000000000 } Here is the playground: https://play.golang.org/p/ZZb7I64BxB Does anyone know a way around this? I know that floats always seem to have issues with comparisons and accuracy but this happens as soon as they become variables. go version go1.7.1 linux/amd64 os: Linux 4.1.12-61.1.14.el7uek.x86_64 GNU/Linux -- 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.