home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUILLET
/
RMEGANUM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
1KB
|
40 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 514 of 517
From : Jason Dyer 1:300/15.0 07 Jul 93 09:07
To : All
Subj : MEGA to Decimal
────────────────────────────────────────────────────────────────────────────────
I guess I'll contribute my two bits...this version is easier to understand
and avoids assembly. It's also MUCH shorter...took me about 10 minutes to
write.}
program ReadMegaNum;
uses Crt;
const Place: array[1..5] of LongInt = (1,36,1296,46656,1679616);
Seq = ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ');
var Loop: Integer;
SSS: string;
Ch: char;
Leave: boolean;
function Convert(SS: string): LongInt;
var PrLoop, Counter: Integer;
CA, Tag: Longint;
begin
Counter:=0; CA:=0;
For PrLoop:=Length(SS) downto 1 do begin
Counter:=Counter+1;
Tag:=Pos(SS[PrLoop],Seq)-1;
CA:=CA+(Tag*Place[Counter]);
end;
Convert:=CA;
end;
begin
ClrScr; Leave:=False;
repeat
Write('Enter number to convert: '); Readln(SSS);
Writeln(Convert(SSS));
Writeln('Do another (Y/N)?');
repeat Ch:=ReadKey; Ch:=Upcase(Ch); until (Ch='Y') or (Ch='N');
If Ch='N' then Leave:=True;
until Leave;
end.