Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Bit ****fti...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 8 Topic 9554 of 9830
Post > Topic >>

Re: Bit ****fting

by nickf3 <nickf3@[EMAIL PROTECTED] > Apr 28, 2008 at 04:07 PM

On Apr 28, 4:13 am, nickf3 <nic...@[EMAIL PROTECTED]
> wrote:
> On Apr 27, 10:13 am, "Brig White" <brighamand...@[EMAIL PROTECTED]
> wrote:
>
> > { Multi-posted article. -mod }
>
> > Why is it than when I bit ****ft to the right with a signed integer
type, all
> > the higher order bits above the move are set but when I ****ft with an
> > unsigned type, they are cleared?
>
> This is how ones' complement signed number representation works.
> For example, 31 in binary (showing only 8 bits) is 00011111
> -31 is then 11100001, i.e. binary complement (all bits flipped)
> plus one (11100000 + 00000001 = 11100001).
>
> ****ft to the right is equivalent to integer division by 2.
> 31/2 = 15 = 00001111 in binary; -31/2 = -15 = 11110001 in binary.
>

Correcting myself:
This, of course, will be -31 >> 1 = -16 = 1111000b,
so negative division by two and the right ****ft are not equivalent.
--
  Nikolai

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 8 Posts in Topic:
Bit shifting
"Brig White" &l  2008-04-27 08:13:20 
Re: Bit shifting
David Shen <davidshen8  2008-04-28 02:13:20 
Re: Bit shifting
nickf3 <nickf3@[EMAIL   2008-04-28 02:13:23 
Re: Bit shifting
nickf3 <nickf3@[EMAIL   2008-04-28 16:07:05 
Re: Bit shifting
Francis Glassborow <fr  2008-04-28 16:03:27 
Re: Bit shifting
nickf3 <nickf3@[EMAIL   2008-04-28 20:36:38 
Re: Bit shifting
Bill Warner <billn@[EM  2008-05-17 23:19:48 
Re: Bit shifting
=?ISO-8859-1?Q?Daniel_Kr=  2008-05-18 10:57:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 15:37:03 CDT 2008.