You are here: Re: confusing >> results « PHP Programming Language « IT news, forums, messages
Re: confusing >> results

Posted by Pedro Graca on 09/27/23 11:37

Chung Leong wrote:
> Palle Hansen wrote:
>> yawnmoth wrote:
>> > <?
>> > echo sprintf('%08x',0x40000000 >> 8)."\n";
>> > echo sprintf('%08x',0x80000000 >> 8);
>> > ?>

>> My guess is that PHP sees 0x8000000 as a *signed* integer

> No, PHP sees 0x80000000 as a double, because the number is beyond the
> range of an integer (on 32 bit systems).

Right, but the >> operator "casts" the float to an int.

~$ php -r '$x = 0x80000000; var_dump($x);'
float(2147483648)

~$ php -r '$x = 0x80000000 >> 0; var_dump($x);'
int(-2147483648)

--
If you're posting through Google read <http://cfaj.freeshell.org/google>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация