Interview Questions

C/C++ Questions only (Floating Point)

C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers


(Continued from previous question...)

C/C++ Questions only (Floating Point)

1. When I set a float variable to 3.1, why is printf printing it as

3.0999999?

2. Why is sqrt(144.) giving me crazy numbers?

3. I keep getting ``undefined: sin'' compilation errors.

4. My floating-point calculations are acting strangely and giving me

different answers on different machines.

5. What's a good way to check for ``close enough'' floating-point

equality?

6. How do I round numbers?

7. Where is C's exponentiation operator?

8. The pre-#defined constant M_PI seems to be missing from <math.h>.

9. How do I test for IEEE NaN and other special values?

10. What's a good way to implement complex numbers in C?

11. I'm looking for some mathematical library code.

12. I'm having trouble with a Turbo C program which crashes and says

something like ``floating point formats not linked.''

(Continued on next question...)

Other Interview Questions