Puzzle 6Please Reboot the Universe
 fn​ ​main​() {
 if​ 0.1 + 0.2 == 0.3 {
  println!(​"Arithmetic still works."​);
  } ​else​ {
  println!(​"Please reboot the universe."​);

Guess the Output


Try to guess what the output is before moving to the next page.


The program will display the following output:

 Please reboot the universe.


You would expect 0.1 + 0.2 to equal 0.3—it does, but not in floating-point ...

Get Rust Brain Teasers now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.