"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/xarm/test/txfrex.c" (12 Dec 2000, 1271 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 /*  txfrex.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:  xfrex  xpr2
   10 
   11     Uses:  atox  prxpr
   12 
   13     Input file: xfrex.dat
   14 */
   15 #define XMATH 1
   16 #include "ccmath.h"
   17 int decd=30;
   18 void main(int na,char **av)
   19 { struct xpr s; int e;
   20   char str[64]; FILE *fp;
   21   if(na!=2){ printf("para: data_file\n"); exit(-1);}
   22   fp=fopen(*++av,"r");
   23   while(fscanf(fp,"%s",str)!=EOF){
   24     s=atox(str);
   25     printf(" s-in="); prxpr(s,decd);
   26 
   27 /* extract exponent of extended precision number */
   28     s=xfrex(s,&e);
   29 
   30     printf(" exp= %d\n",e);
   31     printf(" <s>= "); prxpr(s,decd);
   32 
   33 /* restore exponent of extended precision number */
   34     s=xpr2(s,e);
   35 
   36     printf("  s1= "); prxpr(s,decd);
   37    }
   38 }
   39 /*  Test output
   40 
   41  s-in=  1.234500000000000000000000000000e+0
   42  exp= 1
   43  <s>=   6.172500000000000000000000000000e-1
   44   s1=   1.234500000000000000000000000000e+0
   45  s-in= -2.123450987654321000000000000000e+0
   46  exp= 2
   47  <s>=  -5.308627469135802500000000000000e-1
   48   s1=  -2.123450987654321000000000000000e+0
   49 */