Bug 8415 - некорректная работа с int длиннее 32 бит
Summary: некорректная работа с int длиннее 32 бит
Status: CLOSED NOTABUG
Alias: None
Product: Sisyphus
Classification: Development
Component: php (show other bugs)
Version: unstable
Hardware: all Linux
: P2 critical
Assignee: Alexey Gladkov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-04 22:42 MSK by Nick S. Grechukh
Modified: 2007-03-05 01:29 MSK (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick S. Grechukh 2005-11-04 22:42:02 MSK
php-4.4.1-alt0.cvs20051010
<?
echo decbin(-4339167344);
?>

возвращает 
1000000000000000

та же версия, собранная gcc3.3:
<?
echo decbin(-4339167344);
?>

11111101010111011000111110010000


php-4.4.1 final release страдает тем же, собранный gcc3.4.

предлагается собирать php с gcc 3.3 , как временный workaround
Comment 1 Nick S. Grechukh 2005-11-05 15:21:32 MSK
уточнение:

раньше php просто обрезал старшие биты, и на это, в частности, закладывается код
вычисления контрольной суммы для google rank. 

Comment 2 Alexey Gladkov 2005-11-23 20:28:33 MSK
21.11.05 gcc-3.3 был убран из сизифа.
Comment 3 Andrew Kornilov 2006-01-04 16:01:16 MSK
Так что делать-то будем? На FreeBSD с gcc > 3.4 все работает.
Comment 4 Konstantin A Lepikhov (L.A. Kostis) 2007-03-05 01:29:36 MSK
see http://ru.php.net/manual/ru/function.decbin.php:

1) Returns a string containing a binary representation of the given number
argument. The largest number that can be converted is 4294967295 in decimal
resulting to a string of 32 1's.

2) if you look to source decbin use _php_math_longtobase function where buf type
is unsigned long, so negative numbers is impossible ;)

So it's a normal that this function doesn't work.