Create a 32-bit integer from 2 16-bit integer

  • Thread starter Thread starter Tony Liu
  • Start date Start date
Tony Liu said:
Thanks, in addition, how to create a 64-bit integer from 2 32-bit integers?

Apply the same advice again - the only difference is that you have to
cast the int to long before shifting:

long combined = (((long)highBits)<<32) | lowBits;
 
Thanks again, but how to get back the 2 32-bit integers from the 64-bit
integer?

Thanks in advance
Tony
 
Tony Liu said:
Thanks again, but how to get back the 2 32-bit integers from the 64-bit
integer?

Just use & to mask bits and shift right appropriately. If this isn't
enough, please consult a book about bit shifting - I'm not going to
give you an answer for every single possible thing you might want to do
with bit shifting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Synchsafe Integer 1
data type representations in .NET 6
Last 16 bits 3
How can I get 32-bit Integers? 3
BITs: string to int 4
4byte - value to string (like IPAddress.ToString()) 4
UTF-16 1
Int64 2

Back
Top