On Fri, Apr 30, 2021 at 5:31 PM Kamil Ziemian <kziemian...@gmail.com> wrote: > > Wikipedia says that sqrt(2) = 1.414213562373095048..., so I would round it to > ...0950, while fmt.Println(math.Sqrt2) give me ...0951. > https://en.wikipedia.org/wiki/Square_root_of_2 > > According to https://golang.org/pkg/math/#pkg-constants Sqrt2 is defined with > far more digits, so rounding precision shouldn't be an error. > > Can anyone tell me why math.Sqrt2 have such printing representation? This > little detail is just bogging me. > > I use go version go1.16.3 linux/amd64.
Computer floating point numbers are not ideal floating point numbers. https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html Ian -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWOC_82sHF83wS%3DVRdYtgj8T%3DuQ1ffQgVgaf3MoBOuZCA%40mail.gmail.com.