Re: Generic query about bit opreation in case of 64bit OS.
Re: Generic query about bit opreation in case of 64bit OS.
- Subject: Re: Generic query about bit opreation in case of 64bit OS.
- From: Brian Bergstrand <email@hidden>
- Date: Tue, 1 Jun 2010 15:10:35 +0300
"unsigned long" in LP64 is not 32bits, it is 64bits. Use "unsigned int" for 32bit storage in LP32 and LP64.
On Jun 1, 2010, at 2:47 PM, Arnab Ganguly wrote:
> Dear All,
>
> I am having two below functions.
>
>
>
> void for16(unsigned char *&walker, uint16 &value)
> {
> uint16 result;
>
> result = ((uint16) *walker++) << 0;
> result |= ((uint16) *walker++) << 8;
>
>
> value = result;
> }
>
>
> Here uint16 is unsigned short.
>
>
> void for32(unsigned char *&walker, uint32 &value)
> {
> uint32 result;
>
> result = ((uint32) *walker++) << 0;
> result |= ((uint32) *walker++) << 8;
> result |= ((uint32) *walker++) << 16;
> result |= ((uint32) *walker++) << 24;
>
>
>
> value = result;
> }
>
> Here uint32 is unsigned long.
>
>
> I am not getting same resultant value in case of 32bit and 64bit.How can I make the above code return same result irrespective of 32bit or 64bit machine.I am not clear about the code logic also.Please help me understanding the same.
> Thanks in advance.
> -R
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden