3 ms·
For shits and giggles: $ python3 Python 3.7.4 (default, Sep 7 2019, 18:27:02) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyr
by mrunkel 7y ago
For shits and giggles:
$ python3
Python 3.7.4 (default, Sep 7 2019, 18:27:02)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print (0.1 + 0.1 + 0.1)
0.30000000000000004
$ irb
2.5.1 :001 > print 0.1 + 0.1 + 0.1
0.30000000000000004 => nil
Chrome browser console:
> 0.1 + 0.1 + 0.1
< 0.30000000000000004
$ php
<?php
echo 0.1 + 0.1 + 0.1;
0.3
- samatman 7y agoIs this because PHP is correct, or is it because PHP rounds reprs at a different level of precision?