Puzzle 7 Explanation: NaN
Understand how float numbers can be different from calculated numbers.
We'll cover the following...
Try it yourself
Try executing the code below to see the result for yourself.
Press + to interact
package mainimport ("fmt")func main() {n := 1.1fmt.Println(n * n)}
Explanation
You might have expected 1.21
, which is the right mathematical answer.
When seeing this or similar output, some new developers come to the message boards and say, “We found a bug in Go!” The usual answer is, “Read the manual” ...