home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_USR08B.LHA / gerlib / examples / test / mathtest / TestMath.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  1.1 KB  |  47 lines

  1. #include <exec/types.h>
  2. #include <inline/exec.h>
  3. struct Library *MathTransBase;
  4. struct Library *MathBase;
  5. struct Library *MathIeeeDoubBasBase;
  6. struct Library *MathIeeeDoubTransBase;
  7.  
  8. void close_math(void)
  9. {
  10.     if(MathBase)                 CloseLibrary(MathBase);
  11.     if(MathTransBase)            CloseLibrary(MathTransBase);
  12.     if(MathIeeeDoubBasBase)     CloseLibrary(MathIeeeDoubBasBase);
  13.     if(MathIeeeDoubTransBase)    CloseLibrary(MathIeeeDoubTransBase);
  14. }
  15.  
  16. BOOL init_math(void)
  17. {
  18.     atexit(close_math);
  19.  
  20.     MathBase              = OpenLibrary((STRPTR)"mathffp.library",0L);
  21.     MathTransBase         = OpenLibrary((STRPTR)"mathtrans.library",0L);
  22.     MathIeeeDoubTransBase = OpenLibrary((STRPTR)"mathieeedoubtrans.library",0L);
  23.     MathIeeeDoubBasBase   = OpenLibrary((STRPTR)"mathieeedoubbas.library",0L);
  24.  
  25.     if(MathBase && MathTransBase && MathIeeeDoubTransBase && MathIeeeDoubBasBase)
  26.         return TRUE;
  27.     else return FALSE;
  28. }
  29.  
  30.  
  31. int main(void )
  32. {
  33.     float pi=3.14159265;
  34.     float e=2.71;
  35.     if(init_math())
  36.     {
  37.         /* now we can calculate something */
  38.  
  39.         return e*pi;    /* will be truncated to an int */
  40.     }
  41.     else
  42.     {
  43.         Printf("Not able to open all math-libraries !\n");
  44.         return 20;
  45.     }
  46. }
  47.