|
| |||||||||||||||||||||||||
| scienceskillz (8) | |
|
Hi all, Any idea how to do the following in c++ An integer is entered ie (1320) int mynum = 1320; char highbyte; char lowbyte; What I need to accomplish.... highbyte = 0x05; lowbyte = 0x28; since 0x0528 = 1320; Thanks! | |
|
Last edited on
|
|
| Bazzy (6258) | |
You can get the last byte with mynum & 0xFF, the other one with ( mynum >> 8 ) & 0xFF& is bitwise AND http://en.wikipedia.org/wiki/Bitwise_AND#AND >> is bit shifting http://en.wikipedia.org/wiki/Arithmetic_shift | |
|
|
|