me? https://play.golang.org/p/pJLxBdsZiaJ
I just can't get it, no matter how I look at it
But this is the output I expect to see (same algorithm, different language)
so.. what did you expect?
https://play.golang.org/p/9r9J1Z6wFQ5
Floating point numbers are indeed a difficult topic. The problem here is that the multiplication operation doesn't produce the exact number you expect, instead of 10678.9 you get 10678.900000000001. To be honest, I'm too tired to explain why, but there's another option, just use a library: https://play.golang.org/p/rPF_P2BgllP
if you switch to float32 you can get this result
Обсуждают сегодня