Assignment Help in Turbo 7.0 Pascal - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Assignment Help in Turbo 7.0 Pascal

Posts: 2Member
can anyone help me write code to convert decimal numbers into binary numbers, i know very well how to do soo manually, its how to put my words into my program i need help with, am usuming i use the MOD function.....whatever the case i need some help. Thanks inadvance!

• Posts: 10Member
I'm not sure what tools you have in TP, but here's a couple of algorithms in Basic ..

[code]
sub Bin(x:int)
' converts integer to binary (allowing for negative values) ..
def j:int
def s:string
j = x
if (j < 0) then j = j + 2147483647 + 1

do
s = ltrim\$(str\$(j % 2)) + s
j = j / 2
until j = 0

if (x < 0) then s = "1" + s
return s
endsub

sub Dec(s:string)
' converts binary string to integer ..
def i,result:int
result = 0
for i = 1 to len(s)
if mid\$(s,i,1) = "1" then result = result + 2 ^ (len(s) - i)
next i

return result
endsub
[/code]
• Posts: 163Member
: can anyone help me write code to convert decimal numbers into binary
: numbers, i know very well how to do soo manually, its how to put my
: words into my program i need help with, am usuming i use the MOD
: function.....whatever the case i need some help. Thanks inadvance!