home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / mipsABI / examples / after / ieeemath.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  659 b   |  37 lines

  1. /*
  2.  * illustrate the use of IEEE math
  3.  * test that strtod called with an overflow-causing positive string
  4.  * returns +HUGE and sets errno to ERANGE
  5.  */
  6.  
  7. #include <stdlib.h>
  8. #include <math.h>
  9. #include <errno.h>
  10.  
  11. void prt_error (char *);
  12.  
  13. main()
  14. {
  15.     char *str2 = "+9e+999";
  16.  
  17.     errno = 0;
  18. #ifdef _ABI_SOURCE
  19.     if (strtod (str2, (char **)NULL) != HUGE_VAL)
  20.         prt_error ("FAILED, did not return HUGE_VAL.");
  21. #else
  22.     if (strtod (str2, (char **)NULL) != HUGE)
  23.         prt_error ("FAILED, did not return HUGE.");
  24. #endif
  25.  
  26.     if (errno != ERANGE)
  27.         prt_error ("FAILED, errno not set to ERANGE.");
  28.  
  29. }
  30.  
  31. /* stub for example */
  32. void
  33. prt_error (char *arg)
  34. {
  35.     /*ARGSUSED*/
  36. }
  37.