Hi, how to create a 32-bit integer from 2 16-bit integer?

Thanks

Tony

Shift and or them:

int combined = (highBits << 16) | lowBits;

--

Jon Skeet - < XXXX@XXXXX.COM >

http://www.yqcomputer.com/ ~skeet/

If replying to the group, please do not mail me too

Thanks, in addition, how to create a 64-bit integer from 2 32-bit integers?

Tony

Tony

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;

--

Jon Skeet - < XXXX@XXXXX.COM >

http://www.yqcomputer.com/ ~skeet/

If replying to the group, please do not mail me too

1 loo roll

2. sticky tape

3. glue

Duncan McNutt

Microsoft Product Deactivation Team

2. sticky tape

3. glue

Duncan McNutt

Microsoft Product Deactivation Team

Thanks again, but how to get back the 2 32-bit integers from the 64-bit

integer?

Thanks in advance

Tony

integers?

integer?

Thanks in advance

Tony

integers?

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.

--

Jon Skeet - < XXXX@XXXXX.COM >

http://www.yqcomputer.com/ ~skeet/

If replying to the group, please do not mail me too

1. 16-bit integer ops on 32-bit processor(PowerPC)

2. 16-bit integers on 32-bit machine(PowerPC)

3. writing 16 bit integers instead of 32 bit ?

4. Splitting a 32 bit integer into two unsigned 8 bit integers

6. 32-bit data types vs. 16-bit/8-bit

7. 64-bit and 128 bit integer as a combination of 32-bits

8. D2007: Typecasting 32 bit integer/longword to 32 bit single floating point not possible ?!?

9. 96-bit integer modulo, Athlon64 gcc 64-bit integers, libc codefor 64-bit division, etc.

10. Size 8 bit, 16 bit, 32 bit and 64 bit systems.

11. Declaration to get 8-bit (or 16-bit) integer?

12. [PATCH] utilities: add helper functions for safe 64-bit integer operations as 32-bit halves

13. How much time does it need to sort 1 million random 64-bit/32-bit integers?

7 post • Page:**1** of **1**