#39622 [Opn->Bgs]: overflow on double word
| From: | tony2001@php.net | Date: | Fri, 24 Nov 2006 21:02:26 +0000 |
| Subject: | #39622 [Opn->Bgs]: overflow on double word | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105425@lists.php.net to get a copy of this message | ||
ID: 39622
Updated by: tony2001@php.net
Reported By: diefans at googlemail dot com
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: 2.6.8-2-686-smp GNU/Linux
PHP Version: 5.2.0
New Comment:
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2006-11-24 17:25:13] diefans at googlemail dot com
Description:
------------
php 5.2.0 prints the double values quite well in a string,
but if you do calculations everything goes wrong
Reproduce code:
---------------
<?php
/**
* shows odd behavior with php version 5.2.0
* php version 5.1.4 seems to safe the bits
*/
$a = -5850009183;
$aa = 2739925409;
echo "\ngettype($a):".gettype($a);
echo "\ngettype($aa):".gettype($aa);
echo "\ndechex($a):".dechex($a);
echo "\ndechex($aa):".dechex($aa);
echo "\nhexdec(dechex($a)):".hexdec(dechex($a));
echo "\nhexdec(dechex($aa)):".hexdec(dechex($aa));
echo "\ndecbin($a):".decbin($a);
echo "\ndecbin($aa):".decbin($aa);
echo "\ndecoct($a):".decoct($a);
echo "\ndecoct($aa):".decoct($aa);
echo "\n";
?>
Expected result:
----------------
PHP 5.1.4 (cli) (built: Jul 17 2006 18:15:40):
gettype(-5850009183):double
gettype(2739925409):double
dechex(-5850009183):a34ff1a1
dechex(2739925409):a34ff1a1
hexdec(dechex(-5850009183)):2739925409
hexdec(dechex(2739925409)):2739925409
decbin(-5850009183):10100011010011111111000110100001
decbin(2739925409):10100011010011111111000110100001
decoct(-5850009183):24323770641
decoct(2739925409):24323770641
Actual result:
--------------
PHP 5.2.0 (cli) (built: Nov 19 2006 14:38:41):
gettype(-5850009183):double
gettype(2739925409):double
dechex(-5850009183):80000000
dechex(2739925409):a34ff1a1
hexdec(dechex(-5850009183)):2147483648
hexdec(dechex(2739925409)):2739925409
decbin(-5850009183):10000000000000000000000000000000
decbin(2739925409):10100011010011111111000110100001
decoct(-5850009183):20000000000
decoct(2739925409):24323770641
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39622&edit=1