Possible Duplicate:
PHP Math Precision
The following php code outputs 7 but I expect 8. Why the difference?
Answer
Because due to inaccurate floating point representations, 0.1+0.7 is not exactly equal to 0.8. It might be some very tiny bit less than that. And when you use int(..)
, it truncates it to 7.
No comments:
Post a Comment