Generic query about bit opreation in case of 64bit OS.
Generic query about bit opreation in case of 64bit OS.
- Subject: Generic query about bit opreation in case of 64bit OS.
- From: Arnab Ganguly <email@hidden>
- Date: Tue, 1 Jun 2010 17:17:06 +0530
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