Bug #18157: precision ini value affects internal calculations too
| From: | cnovak at gmx dot net | Date: | Thu, 04 Jul 2002 08:31:38 +0000 |
| Subject: | Bug #18157: precision ini value affects internal calculations too | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-13088@lists.php.net to get a copy of this message | ||
From: cnovak@gmx.net
Operating system: Windows XP Pro
PHP version: 4.2.1
PHP Bug Type: PHP options/info functions
Bug description: precision ini value affects internal calculations too
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 bug report at http://bugs.php.net/?id=18157&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18157&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18157&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18157&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18157&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18157&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18157&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18157&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18157&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18157&r=globals