home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / MATH / ULTRA101.ZIP / DEMO.C next >
Encoding:
C/C++ Source or Header  |  1992-03-26  |  1.3 KB  |  39 lines

  1. /* ULTRA DEMO
  2.  
  3.    This calls the various subroutines of ultra as a test
  4.  
  5. */
  6.  
  7. extern float  uni(void),    vni(void);
  8. extern double duni(void),   dvni(void);
  9. extern long  i32bit(void),  i31bit(void);
  10. extern int   i16bit(void),  i15bit(void);
  11. extern char  i8bit(void),   i7bit(void),   i1bit(void);
  12. extern void  swbfill(void);
  13.  
  14. #define test(format,convert,function,n) \
  15.   rinit(1234567,7654321);       \
  16.   for (i=1;i<10001;i++)         \
  17.   if ((i<n) || (i==10000)) printf(format,convert function()); \
  18.   else function();              \
  19.   printf("\n");
  20.  
  21. main()
  22. { short i;
  23.  
  24.   printf("\nA Sample Printout:\n");
  25.   printf("Signed Double: "); test("%32.15lg",, dvni,2);
  26.   printf("Unsigned Dble: "); test("%32.15lg",, duni,2);
  27.   printf("Signed Single: "); test("%16.7f",,    vni,4);
  28.   printf("Uns. Single:   "); test("%16.7f",,    uni,4);
  29.   printf("Signed 4 byte: "); test("%16li",,  i32bit,4);
  30.   printf("Uns. 4 byte:   "); test("%16li",,  i31bit,4);
  31.   printf("Signed 2 byte: "); test("%8i",,    i16bit,8);
  32.   printf("Uns. 2 byte:   "); test("%8i",,    i15bit,8);
  33.   printf("Signed byte:   "); test("%4hi",(short), i8bit,16);
  34.   printf("Uns. byte:     "); test("%4hi",(short), i7bit,16);
  35.   printf("Random bits:   "); test("%2hi",(short), i1bit,32);
  36.  
  37.   return 0;
  38. }
  39.