What this C++ floating-point behaviour question tests
This is a hard C++ question that probes deep familiarity with how floating-point arithmetic actually works in practice. It sits at the boundary between language knowledge and numerical computing—the kind of gotcha that separates candidates who have merely read the spec from those who have debugged real code involving floats.
Questions like this reward understanding of IEEE 754 semantics, precision loss, implicit conversions, and the subtle ways that floating-point operations diverge from mathematical intuition. Interviewers use them to identify candidates who think carefully about numerical stability and edge cases, skills essential in any quantitative role where numerical correctness matters.
- Floating-point representation and rounding
- Precision loss in arithmetic operations
- Type conversions and implicit casting
- Compiler optimisations affecting float evaluation