REALMATH.DEF 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. (***********************************************************************)
  2. (* *)
  3. (* Modula_2 Compiler RealMath Library Module *)
  4. (* *)
  5. (* Provides a number of mathematical *)
  6. (* functions and REAL/INTEGER conversions *)
  7. (* *)
  8. (* *)
  9. (* original module : ISO WG-13, March 1989 *)
  10. (* modifications : arcsin and arccos not implemented *)
  11. (* *)
  12. (***********************************************************************)
  13. DEFINITION MODULE RealMath;
  14. (* implementation is not FOREIGN for gpm-pc *)
  15. CONST
  16. PI = 3.1415926535897932385;
  17. Exp1 = 2.7182818285450452354;
  18. PROCEDURE sqrt(x : REAL):REAL;
  19. (* Precondition : x is defined and >=0.0
  20. Postcondition : returns the square root of x.
  21. *)
  22. PROCEDURE exp(x : REAL):REAL;
  23. (* Precondition : x is defined.
  24. Postcondition : returns the exponential of x. *)
  25. PROCEDURE ln(x : REAL):REAL;
  26. (* Precondition : x is defined and >= 0.0.
  27. Postcondition : returns the natural logarithm of x. *)
  28. PROCEDURE sin(theta: REAL):REAL;
  29. (* Precondition : theta is defined and is an angle in radians.
  30. Postcondition : returns the sine of theta. *)
  31. PROCEDURE cos(theta: REAL):REAL;
  32. (* Precondition : theta is defined and is an angle in radians.
  33. Postcondition : returns the cosine of theta. *)
  34. PROCEDURE tan(theta : REAL):REAL;
  35. (* Precondition : theta is defined and is an angle in radians.
  36. Postcondition : returns the tangent of x. *)
  37. PROCEDURE arctan(x : REAL):REAL;
  38. (* Precondition : x is defined
  39. Postcondition : returns the arctangent of x expressed in radians. *)
  40. PROCEDURE power(x, y: REAL):REAL;
  41. (* Precondition : true
  42. Postcondition : returns an approximation of 'x' raised to
  43. the power of 'y'. *)
  44. PROCEDURE round(r : REAL):INTEGER;
  45. (* Precondition : r is defined and the result is representable as an
  46. INTEGER.
  47. Postcondition : returns the INTEGER approximation = r. *)
  48. END RealMath.