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

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