home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / doit.zip / DO_MATE.PAS < prev    next >
Pascal/Delphi Source File  |  1989-09-24  |  3KB  |  107 lines

  1. Unit do_mate;
  2.  
  3. (*
  4. ┌───────────────────────────────────────────────────────────────────────────┐
  5. │                         Unidad DO_MATE.PAS                                │
  6. ├───────────────────────────────────────────────────────────────────────────┤
  7. │   Versión             : 1.0                                               │
  8. │   Computadora         : IBM-PC o compatible                               │
  9. │   Lenguaje            : Turbo Pascal 5.5                                  │
  10. │   Autor               : Bernardo Zamora Etcharren                         │
  11. ├──────────────────┬────────────────────────────────────────────────────────┤
  12. │   Explanation :  │                                                        │
  13. ├──────────────────┘                                                        │
  14. │   Contains mathematical functions used in evaluation of RPN function      │
  15. │   (implements functions not present in pascal)                            │
  16. │                                                                           │
  17. └───────────────────────────────────────────────────────────────────────────┘
  18. *)
  19.  
  20. INTERFACE
  21.  
  22. function GRADOS(rad:real):real;
  23. { receives radians and returns grades, ie grados(3.14159265)=180 }
  24.  
  25. function RAD(grados:real):real;
  26. { receives grades and returns radians, ie rad(180)=3.14159265 }
  27.  
  28. function EALA(x:real):real;
  29. { evaluates e elevated to x, ie eala(2)=e^2=2.718^2=7.38 }
  30. { used internally by the program }
  31.  
  32. function TAN(x:real):real;
  33. { sin(x)/cos(x) }
  34.  
  35. function ALA(base,potencia:real):real;
  36. { evaluates b^p, ie 2^3.1 -> ala(2,3.1) = 8.57 }
  37. { used internally by the program }
  38.  
  39. function ALAI(base:real;potencia:integer):real; { INTEGER EXPONENT }
  40. { evaluates b^p, integer exponent, ie 2^3 -> ala(2,3) = 8 }
  41. { used internally by the program }
  42.  
  43. function LOG(x:real):real;
  44. { evaluates the natural logarithm of a real number }
  45.  
  46. Function SGN(x:real):integer;
  47. { Returns the Sign of a number (-1,0,1) }
  48.  
  49.  
  50. IMPLEMENTATION
  51.  
  52.  
  53. function GRADOS(rad:real):real;
  54. begin
  55.   GRADOS := rad * 180 / PI;
  56. end;
  57.  
  58. function RAD(grados:real):real;
  59. begin
  60.   RAD := grados * PI / 180;
  61. end;
  62.  
  63. function EALA(x:real):real;
  64. begin
  65.   EALA := exp(x);
  66. end;
  67.  
  68. function TAN(x:real):real;
  69. begin
  70.   TAN := SIN(x) /  COS(x);
  71. end;
  72.  
  73. function ALA(base,potencia:real):real;
  74. { IF BASE < 0 THIS THING SUCKS }
  75. begin
  76.   ALA := exp(potencia * ln(base))
  77. end;
  78.  
  79. function ALAI(base:real;potencia:integer):real; { INTEGER EXPONENT }
  80. begin
  81.   if base>0 then begin
  82.     ALAI := exp(potencia * ln(base));
  83.   end
  84.   else if base<0 then begin
  85.     ALAI := exp(potencia * ln(-base));
  86.     if odd(potencia) then ALAI := -exp(potencia * ln(-base));
  87.   end
  88.   else {BASE=0}
  89.     ALAI:=0;
  90. end;
  91.  
  92. function LOG(x:real):real;
  93. { it might be accelerated using LN(10) as a constant }
  94. begin
  95.   LOG:=(ln (x) / ln (10) );
  96. end;
  97.  
  98. Function SGN(x:real):integer;
  99. begin
  100.   sgn := 0;
  101.   if x>0 then sgn:=1;
  102.   if x<0 then sgn:=-1;
  103. end;
  104.  
  105.  
  106. begin
  107. end.