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: Arnab Ganguly <email@hidden>
- Date: Tue, 1 Jun 2010 18:01:06 +0530
Thanks for the update. My target OS is 64bit. The above functions works perfectly in 32bit.
First when we call for32 and for16 we get same result both in 32bit and 64bit.But subsequent calls like in a for loop I am not getting the same values. In case of 32bit the above works fine but in case of 64bit only the first iteration gives same values and then onwards it doesn't match with 32bit. In both the cases the array of bytes is same.
Thanks,
-A
On Tue, Jun 1, 2010 at 5:40 PM, Brian Bergstrand
<email@hidden> wrote:
"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