On May 3, 5:45 pm, Charles Sullivan <cwsul...@[EMAIL PROTECTED]
> wrote:
> On Sat, 03 May 2008 14:34:25 +0000, Willem wrote:
> > Charles wrote:
> > )
> > ) Suppose I have this code:
> > )
> > ) unsigned short svalue;
> > ) unsigned char hibyte, lobyte;
> > )
> > ) svalue =3D 0xABCD;
> > )
> > ) hibyte =3D (svalue >> 8) & 0xFF;
> > ) lobyte =3D svalue & 0xFF;
> > )
> > ) Will this result in the values of hibyte and lobyte being 0xAB and
> > 0xCD ) respectively, regardless of whether the platform is little or
big=
> > endian?
>
> > Of course it will. The ****ft operator doesn't care about endianess.
>
> > SaSW, Willem
>
> Thanks Willem. That had been my understanding but some strange bug
> re****ts from users got me wondering whether I was mistaken.
Then perhaps the bug lies somewhere else?
=46rom ISO 9899:1999, 6.5.7:
> The result of E1 >> E2 is E1 right-****fted E2 bit positions.
> If E1 has an unsigned type or if E1 has a signed type and a
> nonnegative value, the value of the result is the integral part
> of the quotient of E1 / 2^(E2) . If E1 has a signed type and a
> negative value, the resulting value is implementation-de=EF=AC=81ned.
(int)(0xABCD / pow(2, 8)) =3D=3D 0xAB (=3D=3D 171)


|