shifting bits, shift 32 bits on 32 bit int
From: GGG (gschoep_at_DigitalGlobe.com)
Date: 05/26/04
- Next message: Steven T. Hatton: "Re: documenting exceptions"
- Previous message: Steven T. Hatton: "Re: is "using namespace std" good style?"
- Next in thread: Victor Bazarov: "Re: shifting bits, shift 32 bits on 32 bit int"
- Reply: Victor Bazarov: "Re: shifting bits, shift 32 bits on 32 bit int"
- Reply: Heinz Ozwirk: "Re: shifting bits, shift 32 bits on 32 bit int"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 May 2004 11:29:07 -0700
Noticed something odd in the way bit shifting was working today.
As far as I have ever heard, shifting will shift in zeros(signed ints
aside)
However I foudn something odd when I am shifting exactly the number of
bits in a value... i.e.
uint32_t x = 5;
uint32_t y = x << 32;
uint32_t z = x << 32;
In the above example y and z are both still 5. Why is this?
Now I understand doing a shift like this seems silly, but in this code
sometimes the resulting shift validly turns out to be exactly the
number of bits in that data type, and expects the result to be 0.
I can change the code to handle this special case... I was just
wondering why this was happening..
- Next message: Steven T. Hatton: "Re: documenting exceptions"
- Previous message: Steven T. Hatton: "Re: is "using namespace std" good style?"
- Next in thread: Victor Bazarov: "Re: shifting bits, shift 32 bits on 32 bit int"
- Reply: Victor Bazarov: "Re: shifting bits, shift 32 bits on 32 bit int"
- Reply: Heinz Ozwirk: "Re: shifting bits, shift 32 bits on 32 bit int"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|