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

Username:   Password: 
 RegisterRegister   
 decimal to binary conversion
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
yodu123




PostPosted: Thu Mar 19, 2009 12:16 am   Post subject: decimal to binary conversion

i just start using Turing. i never used any programing language before and i kinda need some tips on how i can made a conversion from decimals to binary....and also how i can take a number from a textbox (GUI.createtextbox) to be converted into binary digit... appreciate ur help Smile
Sponsor
Sponsor
Sponsor
sponsor
syntax_error




PostPosted: Thu Mar 19, 2009 12:29 am   Post subject: RE:decimal to binary conversion

If you can avoid using the turing GUI at all costs.

Secondly as to your first problem, how would you convert a base 10 number into a base 2 using a pen and paper if you are unaware, and to save me time from typing read the following: http://math.about.com/od/calculuslessons/a/changebase.htm

Google is your friend for further investigation.
yodu123




PostPosted: Thu Mar 19, 2009 9:32 am   Post subject: RE:decimal to binary conversion

i know how to do it on a paper but i have to make a program which converts in order to make a calculator
Insectoid




PostPosted: Thu Mar 19, 2009 10:06 am   Post subject: RE:decimal to binary conversion

Use math in a for loop. Not that div does division with the decimal cut off, and mod does the remainder after division.
DemonWasp




PostPosted: Thu Mar 19, 2009 10:12 am   Post subject: RE:decimal to binary conversion

If you know how to do it on paper, you should be able to convert that to a working program. If not, try and tell us what you're getting confused with.
copthesaint




PostPosted: Fri Mar 20, 2009 4:56 pm   Post subject: RE:decimal to binary conversion

Binary is pretty simple for finding numbers
exapmle 0011 0011 = 51 how do I know this?

the following is a crappy version of a binary table
128 64 32 16 8 4 2 1 - 8bit
-------------------------
0 0 1 1 0 0 1 1 -binary number
ok so really it's simple for every number thats one add the binary number on the table.
1+2+16+32 = 51 not hard right?

now if you have a number bigger then 128, this would get more complicated but <-(Sorry about that) here is example 2 how to change a number to binary
lets use for example 83 not what you want to do is take the largest number on the binary table and add 1 underneath I will now give you the binary of 83,

0101 0011 (83-64=19-16=3-2=1-1=0)
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  [ 6 Posts ]
Jump to:   


Style:  
Search: