Modula-2 || Compiler & Tools || Library || Search Engine


Ulm's Modula-2 Library:
RealConv


NAME

RealConv - conversion of real numbers

SYNOPSIS

TYPE ReadProc = PROCEDURE(VAR CHAR);
VAR Done: BOOLEAN;
VAR termCH: CHAR;


PROCEDURE ReadReal(Read: ReadProc; VAR x: REAL); PROCEDURE WriteFloat(VAR f: ARRAY OF CHAR; x: REAL; base: CARDINAL; dp: CARDINAL); PROCEDURE WriteFix(VAR f: ARRAY OF CHAR; x: REAL; base: CARDINAL; VAR dp: CARDINAL);

DESCRIPTION

RealReal converts a sequence of characters that is generated by Read into a real number that is stored into x. The character sequence is expected to conform to following syntax:
["+" | "-"] digit { digit } ["." digit { digit } ]
["E" ["+" | "-"] digit [digit] ]
The last character returned by Read will be stored into termCH. Read is expected to return 0C in case of errors or end of input.

WriteFloat and WriteFix convert x into an array of characters that is returned in f. Valid bases are 8, 10, and 16. The number of decimal places after the dot is specified by dp. WriteFloat uses a normalized exponent notation while WriteFix suppresses the exponent which may result in very long result strings for very large or small arguments. WriteFix adjusts dp if necessary.

DIAGNOSTICS

Done is TRUE on successfull calls, otherwise FALSE.

SEE ALSO

RealInOut
Edited by: borchert, last change: 1999/01/11, revision: 1.1, converted to HTML: 1999/01/11

Modula-2 || Compiler & Tools || Library || Search Engine