CONVERT.P is a demo program from the Kyan Pascal 2.x Utility Disk 2 for the Atari 8-bit.
It demos how to use the following include files from the Kyan Pascal 2.x Utility Disk 1:
- CONVTYPS.I
- RTOS.I - Real to Integer
- STOR.I - String to Real
- ITOS.I - Integer to String
- STOI.I - String to Integer
If you want to convert from REAL to INTEGER, you can use the built-in ROUND() function. Of course you will lose precision and the mantissa will be removed.
Source Code
PROGRAM CONVERT_DEMO(INPUT,OUTPUT);
TYPE
#I CONVTYPS.I
VAR
NUM :REAL;
JUST:INTEGER;
A :STRING20;
B :STRING5;
C :STRING6;
#I RTOS.I
#I STOR.I
#I ITOS.I
#I STOI.I
BEGIN
NUM:=3.14159;
REALTOSTR(NUM,2,5,A);
WRITELN(A);
A:='3.141592654 ';
WRITELN(STRTOREAL(A));
INTTOSTR(1024,'R',B);
WRITELN(B);
C:='-2355 ';
WRITELN(STRTOINT(C));
END.
No comments:
Post a Comment