The GNU Modula-2 front end to GCC

gm2-libs/dtoa

DEFINITION MODULE dtoa ;

(*
    Description: provides routines to convert between a C double
                 and an ascii string.  The reason we include this
                 module as well as the ldtoa is that the long doubles
                 might be implemented in software on some targets.
                 Hence the libraries should use dtoa if converting
                 REAL or SHORTREAL to/from ascii.
*)

FROM SYSTEM IMPORT ADDRESS ;

TYPE

   Mode = (maxsignificant, decimaldigits) ;


(*
   strtod - returns a REAL given a string, s.  It will set
            error to TRUE if the number is too large.
*)


PROCEDURE strtod (s: ADDRESS; VAR error: BOOLEAN) : REAL ;


(*
   dtoa - converts a REAL, d, into a string.  The address of the
          string is returned.
          mode       indicates the type of conversion required.
          ndigits    determines the number of digits according to mode.
          decpt      the position of the decimal point.
          sign       does the string have a sign?
*)


PROCEDURE dtoa (d        : REAL;
                mode     : Mode;
                ndigits  : INTEGER;
	        VAR decpt: INTEGER;
	        VAR sign : BOOLEAN) : ADDRESS ;


END dtoa.