"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/xarm/test/txlog.c" (24 Oct 2000, 2447 Bytes) of package /linux/misc/old/ccmath-2.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*  txlog.c    CCMATH mathematics library source code.
    2  *
    3  *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved.
    4  *  This code may be redistributed under the terms of the GNU library
    5  *  public license (LGPL). ( See the lgpl.license file for details.)
    6  * ------------------------------------------------------------------------
    7  */
    8 /*
    9     Test:  xlog  xexp
   10 
   11     Uses:  atox  xprcmp  xadd  prxpr
   12 */
   13 #define XMATH 1
   14 #include "ccmath.h"
   15 int decd=30;
   16 void main(void)
   17 { struct xpr z,h,f,w,u;
   18   printf("     Test of Log Function\n");
   19   h=atox(".25"); z=h; w=atox("4.01");
   20   for(; xprcmp(&z,&w)<0 ;z=xadd(z,h,0)){
   21 
   22 /* compute extended precision natural logarithm */
   23     f=xlog(z);
   24     printf(" %8.4f  ",xtodub(z)); prxpr(f,decd);
   25 
   26 /* check using exponential */
   27     u=xexp(f);
   28     printf("   exp(z)  "); prxpr(u,decd);
   29    }
   30 }
   31 /*  Test output
   32 
   33      Test of Log Function
   34    0.2500   -1.386294361119890618834464242916e+0
   35    exp(z)    2.500000000000000000000000000000e-1
   36    0.5000   -6.931471805599453094172321214582e-1
   37    exp(z)    5.000000000000000000000000000000e-1
   38    0.7500   -2.876820724517809274392190059938e-1
   39    exp(z)    7.500000000000000000000000000000e-1
   40    1.0000   -3.948156385993833498764754782299e-33
   41    exp(z)    1.000000000000000000000000000000e+0
   42    1.2500    2.231435513142097557662950903098e-1
   43    exp(z)    1.250000000000000000000000000000e+0
   44    1.5000    4.054651081081643819780131154643e-1
   45    exp(z)    1.500000000000000000000000000000e+0
   46    1.7500    5.596157879354226862708885005268e-1
   47    exp(z)    1.750000000000000000000000000000e+0
   48    2.0000    6.931471805599453094172321214582e-1
   49    exp(z)    2.000000000000000000000000000000e+0
   50    2.2500    8.109302162163287639560262309287e-1
   51    exp(z)    2.250000000000000000000000000001e+0
   52    2.5000    9.162907318741550651835272117680e-1
   53    exp(z)    2.500000000000000000000000000019e+0
   54    2.7500    1.011600911678479925227479335049e+0
   55    exp(z)    2.750000000000000000000000000000e+0
   56    3.0000    1.098612288668109691395245236923e+0
   57    exp(z)    3.000000000000000000000000000000e+0
   58    3.2500    1.178654996341646117219023198649e+0
   59    exp(z)    3.250000000000000000000000000000e+0
   60    3.5000    1.252762968495367995688120621985e+0
   61    exp(z)    3.500000000000000000000000000000e+0
   62    3.7500    1.321755839982319447161540327232e+0
   63    exp(z)    3.750000000000000000000000000000e+0
   64    4.0000    1.386294361119890618834464242916e+0
   65    exp(z)    4.000000000000000000000000000000e+0
   66 */