3 ms·
$ php -v PHP 7.2.10 (cli) (built: Oct 9 2018 14:56:43) ( NTS ) $ php -r "echo 9999999999999999.0 - 9999999999999998.0;" 2 $ php -r "echo bcsub('99999999999
by preinheimer 8y ago
$ php -v
PHP 7.2.10 (cli) (built: Oct 9 2018 14:56:43) ( NTS )
$ php -r "echo 9999999999999999.0 - 9999999999999998.0;"
2
$ php -r "echo bcsub('9999999999999999.0', '9999999999999998.0', 1);"
1.0
bcmath - http://php.net/manual/en/function.bcsub.php http://php.net/manual/en/function.bcsub.php
- blowski 8y agoWhat happens with the bcmath extension enabled?
- preinheimer 8y agogreat point! edited to add. Decimal looks like a good option in php7, but a bit past a command line implementation: http://php-decimal.io/#introduction http://php-decimal.io/#introduction
- deleted 8y ago[deleted]
- mikey_p 8y agoResult for all versions of PHP: https://3v4l.org/JYlrp https://3v4l.org/JYlrp
- mikey_p 8y agoAnd with bcmath: https://3v4l.org/AmOQt https://3v4l.org/AmOQt