Bug #18157 Updated: precision ini value affects internal calculations too
| From: | sander@php.net | Date: | Thu, 04 Jul 2002 08:38:29 +0000 |
| Subject: | Bug #18157 Updated: precision ini value affects internal calculations too | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13091@lists.php.net to get a copy of this message | ||
ID: 18157
Updated by: sander@php.net
Reported By: cnovak@gmx.net
-Status: Open
+Status: Bogus
-Bug Type: PHP options/info functions
+Bug Type: Math related
Operating System: Windows XP Pro
PHP Version: 4.2.1
New Comment:
PHP can't handle numbers larger than 2^32. Use the gmp or bcmath
extension.
(the ini setting precision is only for floats (both calculating and
printing), you're talking about integers).
Previous Comments:
------------------------------------------------------------------------
[2002-07-04 04:31:37] cnovak@gmx.net
By default precision in php.ini is set to 14 significant digits. I
would assume, that this is for printing float results only. Instead,
the precision argument is used for storing values in databases too.
Check the following code:
01 for ($x = 0; $x < 64; $x++) {
02 $group_bitfield = pow(2, $x);
03 print " $group_bitfield<br>";
04 }
The above yields precision errors at 2^48, 2^49, 2^51, 2^52, 2^54. If
this is for output only, fine. But the issue is that these values are
also _incorrectly_ stored in an INT(20) field on MySQL. Explicit type
casting does not help either. Using arbitrary math is not an option for
speed and availabilty at various ISP's.
Configuration:
WINNT
Apache/1.3.26 (Win32) mod_ssl/2.8.10 OpenSSL/0.9.6d PHP version: 4.2.1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18157&edit=1