Puzzle 1Three and a Bit
 fn​ ​main​() {
 const​ THREE_AND_A_BIT : f32 = 3.4028236;
  println!(​"{}"​, THREE_AND_A_BIT);
 }

Guess the Output

images/aside-icons/important.png

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

images/hline.png

The program will display the following output:

 3.4028237
images/hline.png

Discussion

You might have expected the program to print 3.4028236. Surprisingly, the result is off by 0.0000001—you set a value of 3.4028236, yet the result ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.