Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 integer/short to byte array
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chopperdudes




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed May 04, 2011 1:29 pm   Post subject: Re: integer/short to byte array

write the number out
code:

1111000011110000
--------........
   |       |
byte      byte
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DemonWasp




PostPosted: 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).
chopperdudes




PostPosted: 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...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: