home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / MODULAV2GERMAN.DMS / in.adf / Def.zoo / LongRealConversions.def < prev    next >
Encoding:
Modula Definition  |  1988-06-14  |  1.3 KB  |  39 lines

  1. (* $N- *)
  2. DEFINITION MODULE LongRealConversions; (* jr/28mai87 *)
  3.  
  4. PROCEDURE StrToReal(VAR s: ARRAY OF CHAR; VAR r: LONGREAL;
  5.                     VAR err: BOOLEAN);
  6.  
  7. (* Converts input string 's' to a real number 'r'.
  8.  
  9.    Possible error conditions:
  10.     - 's' has a syntactical error
  11.     - 'r' would be too large for a LONGREAL
  12. *)
  13.  
  14.  
  15. PROCEDURE RealToStr(r: LONGREAL; VAR s: ARRAY OF CHAR;
  16.                     m, n: INTEGER; expo: BOOLEAN; VAR err: BOOLEAN);
  17.  
  18. (* Converts the real number 'r' to output string 's'. The output  string  will
  19.    have a length of EXACTLY 'm' characters  (or length of 's'  if  'm'  is too
  20.    large). 'n' is the number of places behind the decimal point. If 'n' is too
  21.    large in respect to 'm' it will be shortened to the maximum possible.If 'n'
  22.    is zero then the decimal point will be omitted.  With 'expo' you can choose
  23.    the exponential mode of output.
  24.    A few examples:   r=12.976   m   n   expo     s
  25.                                 5   2  FALSE  '12.98'
  26.                                 4   2  FALSE  '13.0'
  27.                 3   2  FALSE  ' 13'
  28.                 2   2  FALSE  '13'
  29.                 1   2  FALSE  # err #
  30.                    -8   2  FALSE  '12.98   '
  31.                    10   2   TRUE  '  1.30E+01'
  32.    
  33.    Possible error conditions:
  34.     - 'm' is zero OR 'n' is negative
  35.     - 's' is to small to hold the string representing 'r'
  36. *)
  37.  
  38. END LongRealConversions.
  39.