home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST145.PRG < prev    next >
Encoding:
Text File  |  1989-08-08  |  1.4 KB  |  53 lines

  1. ********************
  2.  
  3. FUNCTION Cosin
  4.  
  5.    * Written and contributed by ESSOR MASO
  6.    *
  7.    * For the input argument in the first circle, degrees -360 <=arg <=360.
  8.    * The error ABS(e(arg)) <= 2*10^(-9); the value 2 is returned if 
  9.    * either the argument or the D or R is missing, or the ABS(arg) > 360.
  10.    *
  11.    * Correct form: COSIN(arg,'D')
  12.    *
  13.    * National Bureau of Standards Handbook of Mathematical Functions
  14.  
  15.    PARAMETERS _coswork, _cosdeg
  16.  
  17.    IF TYPE("_coswork") + TYPE("_cosdeg") != "NC"
  18.       RETURN(2)
  19.    ENDIF
  20.  
  21.    SET DECIMAL TO 10
  22.  
  23.    PRIVATE _cosint, _cossqu
  24.  
  25.    _cossign = IF(_coswork < 0, .T., .F.)
  26.    IF ABS(IF(UPPER(_cosdeg)#'D',_coswork,_coswork*1.5707963268/90))>6.2831853072 .OR. PCOUNT() # 2
  27.       RETURN(2)
  28.    ENDIF
  29.  
  30.    _coswork = ABS(IF(UPPER(_cosdeg)#'D',_coswork,_coswork*1.5707963268/90))
  31.    _cosint  = MODULUS(INT(_coswork/1.5707963268),4)
  32.    _coswork = MODULUS(_coswork,1.5707963268)
  33.  
  34.    IF _cosint=1.OR._cosint=3
  35.       _coswork=1.5707963268-_coswork
  36.    ENDIF
  37.    STORE _coswork*_coswork TO _coswork,_cossqu
  38.  
  39.    _coswork = .0000247609-.0000002605*_cossqu
  40.    _coswork = -.0013888397+_coswork*_cossqu
  41.    _coswork = .0416666418+_coswork*_cossqu
  42.    _coswork = -.4999999963+_coswork*_cossqu
  43.    _coswork = ROUNDING(1+_coswork*_cossqu,8)
  44.  
  45.    IF _cosint = 1.OR._cosint=2
  46.       _coswork = -_coswork
  47.    ENDIF
  48.    RETURN(_coswork)
  49.  
  50. * End of File
  51.  
  52.  
  53.