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 > Re: little/big ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 6 Topic 26050 of 26955
Post > Topic >>

Re: little/big endian question.

by vippstar@[EMAIL PROTECTED] May 3, 2008 at 09:21 AM

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)
 




 6 Posts in Topic:
little/big endian question.
Charles Sullivan <cwsu  2008-05-03 14:29:24 
Re: little/big endian question.
Willem <willem@[EMAIL   2008-05-03 14:34:25 
Re: little/big endian question.
vippstar@[EMAIL PROTECTED  2008-05-03 09:21:28 
Re: little/big endian question.
Charles Sullivan <cwsu  2008-05-03 14:45:05 
Re: little/big endian question.
Martin <martindotounde  2008-05-04 20:27:40 
Re: little/big endian question.
Ben Bacarisse <ben.use  2008-05-04 22:00:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Thu Jul 24 2:15:27 CDT 2008.