Computer Science Canada

decimal to binary conversion

Author:  yodu123 [ 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

Author:  syntax_error [ 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.

Author:  yodu123 [ 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

Author:  Insectoid [ 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.

Author:  DemonWasp [ 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.

Author:  copthesaint [ 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)


: