by panic · 11y ago · 0 comments
php > echo .1 + .2;
0.3
php > if (.1 + .2 === .3) { echo "equal"; } else { echo "not equal"; }
not equalOne of the cardinal rule of floating point in computing is that you never do direct comparison between values, whatever the language, so your test should never ever be used. That doesn't mean a language cannot be allowed to infer what the correct display of a floating point value should be.