Help with Number Conversions 
Author Message
 Help with Number Conversions

Hi

I have to write a program that will perform number conversions. The
number that i have to convert will allways be a base 10 number. My
program has to be  able to convert it to base-2 or base-8.  

I know i have to make use of linked list and traverse the linked list to
get the answer - but not sure how to do this.

Please help
thanks
Marius



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with Number Conversions



Quote:
>Hi

>I have to write a program that will perform number conversions. The
>number that i have to convert will allways be a base 10 number. My
>program has to be  able to convert it to base-2 or base-8.  

>I know i have to make use of linked list and traverse the linked list to
>get the answer - but not sure how to do this.

>Please help
>thanks
>Marius


Linked list???

The standard procedure for such (integer) number conversions is to repeatedly
divide the source number with the target base and build the target number
(from right to left) using the remainders.

Example: 20 base 10 to base 8:
20 div 8 = 2 with remainder 4
2 div 8 = 0 with remainder 2
so 20 base 10 equals 24 base 8

Given this example you should easily be able to convert to other bases, and
also to extend the procedure to handle fractions if required. (Hint: Use
multiply instead of divide).

By the way: If this is some kind of a student homework you surely have a tutor
to ask for help?

regards Sven



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with Number Conversions


|> Hi
|>
|> I have to write a program that will perform number conversions. The
|> number that i have to convert will allways be a base 10 number. My
|> program has to be  able to convert it to base-2 or base-8.  
|>
|> I know i have to make use of linked list and traverse the linked list to
|> get the answer - but not sure how to do this.

You don't need linked lists (a string to store the numbers in
should suffice) and basically only need DIV and MOD

Hope this helps

 -Mike



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with Number Conversions



:I have to write a program that will perform number conversions. The
:number that i have to convert will allways be a base 10 number. My
:program has to be  able to convert it to base-2 or base-8.  

42) How do I convert a decimal word into a hexadecimal string, etc?

 99848 May 19 1996 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers

:I know i have to make use of linked list and traverse the linked list to
:get the answer - but not sure how to do this.

No, you don't have to make it that complicated.

   All the best, Timo

....................................................................

Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Numbers Conversion

2. number conversion in pascal

3. Conversion from numbers to words

4. base conversion of large numbers

5. base conversion of large numbers

6. Number conversions

7. Tutorial on number conversion, any base

8. Program for number conversion, bases 2..72

9. Tutorial on number conversion, any base

10. Program for number conversion, bases 2..72

11. Coding conversions from negative decimals to signed two's compliment binary number -- PLEASE HELP!!!

12. Help needed in number conversions!! PLEASE!

 

 
Powered by phpBB® Forum Software