There are 3rd-party packages/vendors that help with this, such as: https://github.com/shopspring/decimal
On Thursday, November 9, 2017 at 5:36:03 PM UTC-6, Erik Swan wrote: > > Why are the following unequal in Go? Is this a bug, or is it by design? If > it's by design, why does this occur and is this type of behavior documented > anywhere? > > https://play.golang.org/p/itEV9zwV2a > > package main > > import ( > "fmt" > ) > > func main() { > x := 10.1 > > fmt.Println("x == 10.1: ", x == 10.1) > fmt.Println("x*3.0 == 10.1*3.0:", x*3.0 == 10.1*3.0) > fmt.Println("x*3.0: ", x*3.0) > fmt.Println("10.1*3.0: ", 10.1*3.0) > } > > Produces: > > x == 10.1: true > x*3.0 == 10.1*3.0: false > x*3.0: 30.299999999999997 > 10.1*3.0: 30.3 > > > -- 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.