[comp.os.os9] Clibt math library man page

pete@wlbr.EATON.COM (Pete Lyall) (03/14/89)

Because of numerous requests, I am posting the man page to the
enhanced math functions in the 'clibt.l' C library. I am also postin a
correction to the rand()/srand() functions.

Note: the rand() and srand() functions below are WRONG. The
rand() function returns a LONG, and accepts no scale factor. The
application must scale it itself. Also, the srand() function accepts a
LONG as an argument. A good seed might be data returnrd by the unix-ish 
time() function.


Pete Lyall
================================ Cut here =========================

    MATH(3C)                 Kreider OS-9 C Library                 MATH(3C)


    NAME 

         rand, srand, sqrt, unmin, unmax, max, min - Math functions 

    SYNOPSIS 

         rand(sf) int sf; 
         
         srand(n) int n; 
         
         int sqrt(n) int n; 
         
         int max(v1, v2) int min(v1, v2) int v1, v2; 
         
         int unmax(v1, v2) int unmin(v1, v2) unsigned v1, v2; 

    DESCRIPTION 

         RAND  returns  a random number in the range of the scale factor SF.
         SRAND seeds the random number generator.  SRAND uses the dual table 
         method proposed by Knuth.  
         
         SQRT returns the square root of the number N which must be  a  type
         INTEGER number.  
         
         MAX and MIN select either the larger of the smaller of variables V1 
         and V2.  UNMAX and UNMIN perform the same function, but on unsigned 
         numbers.  Each of these functions returns a type INTEGER number.  

    SEE ALSO 

         clibt.l Transentental Math library.


























    Last Revision: 3/13/89                                            Page 1



================================ Cut here ============================


        CLIBT.L              Kreider OS-9 C Library               CLIBT.L


        The  following  functions  are  additions  to  the Kreider CLIB.L
        functions described earlier, and all the functions  contained  in
        that library  are  also  present  here.    The  purpose  of  this
        additional  library  is  to  provide  the   transcentental   math
        functions.   All  the  remaining functions perform in exactly the
        same manner as in the CLIB.L library, but are rewritten here  for
        increased  speed  in  execution,  although  resulting in a larger
        output file.  


        NAME 

             Transcentental Math C Library

        SYNOPSIS

             rad()
             
             deg()
             
             double acos(x)
             double x;
             
             double asin(x)
             double x;
             
             double atan(x)
             double x;
             
             double cos(x)
             double x;
             
             double sin(x)
             double x;
             
             double tan(x)
             double x;
             
             double acosh(x)
             double x;
             
             double asinh(x)
             double x;
             
             double atanh(x)
             double x;
             
             double cosh(x)
             double x;
             
             double sinh(x)
             double x;
             
             double tanh(x)




        Last Revision: 3/13/89                                    Page 61




        CLIBT.L              Kreider OS-9 C Library               CLIBT.L


             double x;
             
             double pow(x,y)
             double x,y;
             
             double exp(x)
             double x;
             
             double antilg(x)
             double x;
             
             double log10(x)
             double x;
             
             double log(x)
             double x;
             
             double sqrt(x)
             double x;
             
             double sqr(x)
             double x;
             
             double inv(x)
             double x;
             
             double dabs(x)
             double x;
             
             double dexp(x,i)
             double x;
             int i;

        DESCRIPTION

             The various transcendental math  functions  are  implemented
             here using  the  CORDIC method.  Accuracy is to sixteen (16)
             decimal places.  The four basic math functions are rewritten 
             to optimize for speed  at  the  expense  of  output  program
             length.    This  gives  at  least  a  factor  of  two  speed
             improvement over the standard Microware C library.  
             
             Externally, all number look just like a normal C double, but 
             internally, an extra byte is  used  to  permit  an  exponent
             range of 511.  
             
             RAD() changes the trigometric functions to radians.  
             
             DEG() changes the trigometric functions to degrees.  
             
             ACOS(x) returns the arc cosine of X.  
             
             ASIN(x) returns the arc sine of X.  
             




        Last Revision: 3/13/89                                    Page 62




        CLIBT.L              Kreider OS-9 C Library               CLIBT.L


             ATAN(x) returns the arc tangent of X.  
             
             COS(x) returns the cosine of X.  
             
             SIN(x) returns the sine of X.  
             
             TAN(x) returns the tangent of X.  
             
             ACOSH(x) returns the arc hyperbolic cosine of X.  
             
             ASINH(x) returns the arc hyperbolic sine of X.  
             
             ATANH(x) returns the arc hyperbolic tangent of X.  
             
             COSH(x) returns the hyperbolic cosine of X.  
             
             SINH(x) returns the hyperbolic sine of X.  
             
             TANH(x) returns the hyperbolic tangent of X.  
             
             POW(x,y) returns the value of X taken to the power of Y.  
             
             EXP(x) returns E to the X power.  
             
             ANTILG(x) returns 10 to the X power.  
             
             LOG10(x) returns logarithm base 10 of X.  
             
             LOG(x) returns the logarithm base E of X.  
             
             SQRT(x) returns the square root of X.  
             
             SQR(x) returns the square of X.  
             
             INV(x) returns the value of 1 (one) divided by X.  
             
             DABS(x) returns the absolute value of X.  
             
             DEXP(x,i)  returns  the  value of X multiplied by 2 to the i
             power.  This is a VERY QUICK function.  

        NOTE 

             The following errors are  returned  by  each  of  the  above
             functions  if  an  error occurs and are placed in the global
             variable ERRNO.  
             
             These error numbers should be added to ERRNO.H:
             
                  EFPOVR  40      Floating point overflow
                  EDIVERR 41      Divide by zero error
                  EINTERR 42      Overflow on conversion of a double integer
                  EFPUND  43      Floating point underflow (does not abort
                                  the program). Zero is returned.




        Last Revision: 3/13/89                                    Page 63




        CLIBT.L              Kreider OS-9 C Library               CLIBT.L


                  EILLARG 44      Illegal function argument, e.g  sqrt(-1)

        SEE ALSO

             math().





















































        Last Revision: 3/13/89                                    Page 64
-- 
Pete Lyall                                           Contel Corp.(818)-706-5693
Compuserve: 76703,4230 (OS9 Sysop)  OS9_Net: (805)-985-0632 (24hr 300/1200/2400)
Internet: pete@wlbr.eaton.com           UUCP: {hacgate,jplgodo,voder}!wlbr!pete