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

Posted by Pedro Graca on 09/28/22 11:37

Pedro Graca wrote:
> yawnmoth wrote:
>> Why should >> even be concerned with whether or not integers are signed?
>
> ~$ php -r 'echo -8 >> 2, "\n";'

I forgot the rest of the post ...

Let's say -8 in binary is (ignore the spaces)
MSB == 10000000 00000000 00000000 00001000 == LSB

if you shift this right without concern for the sign, you get
MSB == 00100000 00000000 00000000 00000010 == LSB

which is 536870914


Do you think -8 >> 2 (-8 divided by 4) should equal 536870914? :)

--
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

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