RealConver.def 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. DEFINITION MODULE RealConversions;
  2. (*
  3. Module: string-to-real and real-to-string conversions
  4. Author: Ceriel J.H. Jacobs
  5. Version: $Id$
  6. *)
  7. PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
  8. (* Convert string "str" to a real number "r" according to the syntax:
  9. ['+'|'-'] digit {digit} ['.' digit {digit}]
  10. ['E' ['+'|'-'] digit {digit}]
  11. ok := "conversion succeeded"
  12. Leading blanks are skipped;
  13. Input terminates with a blank or any control character.
  14. *)
  15. PROCEDURE StringToLongReal(str: ARRAY OF CHAR;
  16. VAR r: LONGREAL;
  17. VAR ok: BOOLEAN);
  18. PROCEDURE RealToString(r: REAL;
  19. width, digits: INTEGER;
  20. VAR str: ARRAY OF CHAR;
  21. VAR ok: BOOLEAN);
  22. (* Convert real number "r" to string "str", either in fixed-point or
  23. exponent notation.
  24. "digits" is the number digits to the right of the decimal point,
  25. "width" is the maximum width of the notation.
  26. If digits < 0, exponent notation is used, otherwise fixed-point.
  27. If fewer than "width" characters are needed, leading blanks are inserted.
  28. If the representation does not fit in "width", then ok is set to FALSE.
  29. *)
  30. PROCEDURE LongRealToString(r: LONGREAL;
  31. width, digits: INTEGER;
  32. VAR str: ARRAY OF CHAR;
  33. VAR ok: BOOLEAN);
  34. END RealConversions.