|
-
May 6th, 2001, 06:57 AM
#1
Thread Starter
Member
decimal/binary convert - repetition functions
im trying to make a binary/decimal convertor using repetition functions and no built in function. im having problems declaring the variables and using them in my algorithms. please help!!
--dec to bin--
set the bitstring to nothing
for each bit required in the bitstring
Calculate the remainder when the number is divided by 2
Number = Number \ 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
next bit
output the bitstring
--dec to bin--
set the bitstring to nothing
Do
Calculate the remainder when the number is divided by 2
Number = Number \ 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
loop until Number is zero
output the bitstring
--bin to dec--
Number = 0
for each character in the bitstring
Determine the value of the bit
Number = Number * 2 + Value of the bit
next character (moving rightwards through the bitstring)
output the Number
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|