3 ms·
This is more a comparison of output routines than anything else. In PHP, one of the languages that gives the "correct" result: php > echo .1 + .2; 0.3
by panic 11y ago
This is more a comparison of output routines than anything else. In PHP, one of the languages that gives the "correct" result:
php > echo .1 + .2;
0.3
php > if (.1 + .2 === .3) { echo "equal"; } else { echo "not equal"; }
not equal
- nolok 11y agoErrr that's exactly what the page implies; it does not say nor imply "those that display .3 are doing it correctly internaly". One 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.
- deleted 11y ago[deleted]