[comp.lang.pascal] converting decimals

R1TMARG%AKRONVM.BITNET@cornellc.cit.cornell.edu (Tim Margush) (10/19/89)

>From: Ken Johnson <ken@aiai.edinburgh.ac.uk>
>Newsgroups: comp.lang.pascal
>Subject: Base conversion (was Re: Brain Teaser)
>Message-ID: <1246@skye.ed.ac.uk>
>Date: 18 Oct 89 09:42:30 GMT
>Followup-To: comp.lang.pascal
>To:       info-pascal@vim.brl.mil
>
>>  Write a routine that will convert from one base to another.
>>       function convert(base : integer; input_num : string) : string;
>
>Can anyone extend this to cover multi-base arithmetic with fractions?
>For example, 1.4(8) should convert to 1.1(2) and
>10.875(10) to A.E(16)
A bit more must be specified here.  For example what is to be done
with .1(ten) when converting to base two?

How many decimal places? or hor should the repeating section be
identified?  I have assigned this problem to my Computer Programming
II class as a programming assignment.  I had them indicate a repeating
group of digits in parenthesis, thus 1/3 (ten) would be written as
0.(3) base ten.  I did not have them process inputs of this form, only
to display their output.  An input of 3.1 (ten) converted to base two
would be displayed as 11.0(0011) (two) or 3.1(9) (hex) or 3.0(6314)
(eight).


---------------------------------------------------------------------
Tim Margush                                    R1TMARG@AKRONVM.BITNET
Department of Mathematical Sciences         R1TMARG@VM1.CC.UAKRON.EDU
University Of Akron                        R1TMARG@AKRONVM.UAKRON.EDU
Akron, OH 44325                                        (216) 375-7109