Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
C offers multiple floating-point types: float, double, and long double. Developers often choose double for general numerical work. When extreme ranges or additional precision are required, long double may help. This question checks your practical understanding of when long double is appropriate.
Given Data / Assumptions:
Concept / Approach:
On many systems, long double uses a format with greater exponent range and/or precision (for example, 80-bit extended on x86 or 128-bit quadruple on some toolchains). Therefore, when a value exceeds the range of double or requires more precision, long double can be selected to mitigate overflow or reduce rounding error. However, portability requires checking the actual limits via LDBL_MAX and LDBL_DIG in
Step-by-Step Solution:
Verification / Alternative check:
Print DBL_MAX vs LDBL_MAX at runtime to confirm capacity; verify numerical results remain finite and precise under long double where double overflowed or lost precision.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming long double is always wider; on some ABIs it equals double. Always check float.h for portable code.
Final Answer:
Correct.
Discussion & Comments