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

Posted by Jerry Stuckle on 09/28/13 11:37

Pedro Graca wrote:
> 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? :)
>

But -8 binary is:

11111111 11111111 11111111 11111000

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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