integer/short to byte array
Author |
Message |
chopperdudes
|
Posted: Wed May 04, 2011 1:10 pm Post subject: integer/short to byte array |
|
|
pretty much... google tells me how to do it in java, and i wasn't successful at finding out how to do it "manually". I'm not very good at these low level stuff, but am thinking of using turing's net commands and making a communication link between 2 programs. i think stuff might work if i can somehow converted for example a short to a byte array of length 2 and an int to a byte array of length 4.
is there any way to do this in turing? or how would you do it manually (i.e. on paper if this is possible)?
thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed May 04, 2011 1:29 pm Post subject: Re: integer/short to byte array |
|
|
write the number out
code: |
1111000011110000
--------........
| |
byte byte
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Wed May 04, 2011 1:35 pm Post subject: RE:integer/short to byte array |
|
|
Within Turing, you will want what are called "bitwise operators". In Turing, those are shl, shr, or, and (shift left, shift right, bitwise-or, bitwise-and). |
|
|
|
|
![](images/spacer.gif) |
chopperdudes
|
Posted: Wed May 04, 2011 1:53 pm Post subject: RE:integer/short to byte array |
|
|
oh i see thanks, tony's explaination was pretty much what i was looking for.
also... now that i look into it... might as well just use java for the TCP/IP communication link... |
|
|
|
|
![](images/spacer.gif) |
|
|