rotovegasBoy
Programmer
We're using some code that needs to take a 64 bit timestamp value and use 36 bits of it. Heres the situation.
The 64 bit value is read from hardware into two 32bit variables upper and lower we want to discard the 4 least significant bits of lower and shift the number 4 bits to the left. this is added to the 4 least significant bits of upper which have been shifted right 28 bits so the resultant number looks like this:
0xULLLLLLL. theres the code wee're using now
/*assume upper and lower have been loaded correctly and declared*/
lower = lower >> 4;
upper = upper << 28;
result = lower + upper;
return result;
Is there anything immediately wrong with this code?
Also we cant just use a long data type because its on an embedded system with a propreitry OS and the biggest data type is unsigned 32bits.
Thanks X-)
Chris Packham
If a tree falls in the woods and it hits Bill Gates does anyone care?
The 64 bit value is read from hardware into two 32bit variables upper and lower we want to discard the 4 least significant bits of lower and shift the number 4 bits to the left. this is added to the 4 least significant bits of upper which have been shifted right 28 bits so the resultant number looks like this:
0xULLLLLLL. theres the code wee're using now
/*assume upper and lower have been loaded correctly and declared*/
lower = lower >> 4;
upper = upper << 28;
result = lower + upper;
return result;
Is there anything immediately wrong with this code?
Also we cant just use a long data type because its on an embedded system with a propreitry OS and the biggest data type is unsigned 32bits.
Thanks X-)
Chris Packham
If a tree falls in the woods and it hits Bill Gates does anyone care?