4 ms·
If you want PHP to print it like the other languages you have to set the output precision high enough. The default, as you mentioned, is 14 but if you set it to
by lsaferite 11y ago
If you want PHP to print it like the other languages you have to set the output precision high enough. The default, as you mentioned, is 14 but if you set it to 17 then you get the 'correct' output.
https://3v4l.org/TRcJB https://3v4l.org/TRcJB
http://php.net/manual/en/ini.core.php#ini.precision http://php.net/manual/en/ini.core.php#ini.precision
- McGlockenshire 11y agoAnother option is to use printf, as like other languages it can take a precision argument. printf('%.17f', 0.1 + 0.2); // 0.30000000000000004