From:             diefans at googlemail dot com
Operating system: 2.6.8-2-686-smp GNU/Linux
PHP version:      5.2.0
PHP Bug Type:     Variables related
Bug description:  overflow on double word

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 bug report at http://bugs.php.net/?id=39622&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39622&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39622&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39622&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39622&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39622&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39622&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39622&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39622&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39622&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39622&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39622&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39622&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39622&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39622&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39622&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39622&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39622&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39622&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39622&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39622&r=mysqlcfg

Reply via email to