combine 2 bytes into 1 word
archer1424
Posts: 7
Hi all,
I'm am reading in coordinate data from a pcap screen (serially) and I am having a simple problem. The x and y coordinate data comes in as 2 bytes each, so I need to combine the two bytes together so I can use the single binary value. My first attempt used a two element byte sized array. I placed the first byte in array[0] and the second in array[1]. when I print the result to the terminal I only get the first byte with many leading 0s. Is this the correct approach, or am I missing something simple?
Thanks
Dan
I'm am reading in coordinate data from a pcap screen (serially) and I am having a simple problem. The x and y coordinate data comes in as 2 bytes each, so I need to combine the two bytes together so I can use the single binary value. My first attempt used a two element byte sized array. I placed the first byte in array[0] and the second in array[1]. when I print the result to the terminal I only get the first byte with many leading 0s. Is this the correct approach, or am I missing something simple?
Thanks
Dan
Comments
propeller- spin
I apologize for my terrible forum etiquette, now I know. The .byte[n] worked perfectly!
Thanks
Dan