A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-68.cpp
1#include<iostream>
2intmain(){
3floatf=0.1f;
4doubled=f;
5std::cout<<(d==0.1)<<"\n";
6return0;
7}
Conversions
Answer & explanation
Console output
0
Why
The literal 0.1f is the nearest float to 0.1, and widening it to double preserves that float-level rounding error. The double literal 0.1 is a closer (but different) approximation, so the two values differ and d == 0.1 is false, printing 0. The float-to-double conversion is exact, but it cannot recover precision the float never had.