home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 25.ddi / root.2 / usr / ucbinclude / fp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  6.0 KB  |  201 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10.  
  11. #ident    "@(#)//usr/ucbinclude/fp.h.sl 1.1 4.0 12/08/90 26136 AT&T-USL"
  12.  
  13. /*******************************************************************
  14.  
  15.         PROPRIETARY NOTICE (Combined)
  16.  
  17. This source code is unpublished proprietary information
  18. constituting, or derived under license from AT&T's UNIX(r) System V.
  19. In addition, portions of such source code were derived from Berkeley
  20. 4.3 BSD under license from the Regents of the University of
  21. California.
  22.  
  23.  
  24.  
  25.         Copyright Notice 
  26.  
  27. Notice of copyright on this source code product does not indicate 
  28. publication.
  29.  
  30.     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  31.     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  32.               All rights reserved.
  33. ********************************************************************/ 
  34.  
  35. /*
  36.  * IEEE floating-point definitions for constants, types, variables, and
  37.  * functions implemented in libc.a for: IEEE floating-point arithmetic base
  38.  * conversion; IEEE floating-point arithmetic modes; IEEE floating-point
  39.  * arithmetic exception handling; certain functions defined in 4.3 BSD and
  40.  * System V.
  41.  */
  42.  
  43. #ifndef _floatingpoint_h
  44. #define _floatingpoint_h
  45.  
  46. #include <sys/ieeefp.h>
  47.  
  48. /* Sun TYPES for IEEE floating point.     */
  49.  
  50. typedef float   single;
  51. typedef unsigned long extended[3];    /* MC68881/i80387 double-extended type. */
  52. typedef struct {
  53.     unsigned long   u[4];
  54. }               quadruple;    /* Quadruple-precision type. */
  55.  
  56. #define N_IEEE_EXCEPTION 5    /* Number of floating-point exceptions. */
  57.  
  58. typedef unsigned fp_exception_field_type;
  59. /*
  60.  * A field containing fp_exceptions OR'ed together.
  61.  */
  62.  
  63. typedef int     sigfpe_code_type;    /* Type of SIGFPE code. */
  64.  
  65. typedef void    (*sigfpe_handler_type) ();
  66. /* Pointer to exception handler function. */
  67.  
  68. #define SIGFPE_DEFAULT    (void (*)())0    /* default exception handling */
  69. #define SIGFPE_IGNORE    (void (*)())1    /* ignore this exception or code */
  70. #define SIGFPE_ABORT    (void (*)())2    /* force abort on exception */
  71.  
  72. /* Sun VARIABLES for IEEE floating point. */
  73.  
  74. extern enum fp_direction_type fp_direction;
  75. /*
  76.  * Current rounding direction. Updated by ieee_flags.
  77.  */
  78.  
  79. extern enum fp_precision_type fp_precision;
  80. /*
  81.  * Current rounding precision. Updated by ieee_flags.
  82.  */
  83.  
  84. extern fp_exception_field_type fp_accrued_exceptions;
  85. /*
  86.  * Sticky accumulated exceptions, updated by ieee_flags. In hardware
  87.  * implementations this variable is not automatically updated as the hardware
  88.  * changes and should therefore not be relied on directly.
  89.  */
  90.  
  91. /* Sun definitions for base conversion.             */
  92.  
  93. #define DECIMAL_STRING_LENGTH 512
  94. /* Size of buffer in decimal_record. */
  95.  
  96. typedef char    decimal_string[DECIMAL_STRING_LENGTH];
  97. /* Decimal significand. */
  98.  
  99. typedef struct {
  100.     enum fp_class_type fpclass;
  101.     int             sign;
  102.     int             exponent;
  103.     decimal_string  ds;    /* Significand - each char contains an ascii
  104.                  * digit, except the string-terminating ascii
  105.                  * null. */
  106.     int             more;    /* On conversion from decimal to binary, != 0
  107.                  * indicates more non-zero digits following
  108.                  * ds. */
  109.     int             ndigits;/* On fixed_form conversion from binary to
  110.                  * decimal, contains number of digits
  111.                  * required for ds. */
  112. }
  113.                 decimal_record;
  114.  
  115. enum decimal_form {
  116.     fixed_form,        /* Fortran F format: ndigits specifies number
  117.                  * of digits after point; if negative,
  118.                  * specifies rounding to occur to left of
  119.                  * point. */
  120.     floating_form        /* Fortran E format: ndigits specifies number
  121.                  * of significant digits. */
  122. };
  123.  
  124. typedef struct {
  125.     enum fp_direction_type rd;
  126.     /* Rounding direction. */
  127.     enum decimal_form df;    /* Format for binary to decimal conversion. */
  128.     int             ndigits;/* Number of digits for conversion. */
  129. }
  130.                 decimal_mode;
  131.  
  132. enum decimal_string_form {    /* Valid decimal number string formats. */
  133.     invalid_form,        /* Not a valid decimal string format. */
  134.     whitespace_form,    /* All white space - valid in Fortran! */
  135.     fixed_int_form,        /* <digs>          */
  136.     fixed_intdot_form,    /* <digs>.          */
  137.     fixed_dotfrac_form,    /* .<digs>         */
  138.     fixed_intdotfrac_form,    /* <digs>.<frac>     */
  139.     floating_int_form,    /* <digs><exp>         */
  140.     floating_intdot_form,    /* <digs>.<exp>         */
  141.     floating_dotfrac_form,    /* .<digs><exp>         */
  142.     floating_intdotfrac_form,    /* <digs>.<digs><exp>     */
  143.     inf_form,        /* inf             */
  144.     infinity_form,        /* infinity         */
  145.     nan_form,        /* nan             */
  146.     nanstring_form        /* nan(string)         */
  147. };
  148.  
  149. /*    The following externs are used in the implementation of sprintf.        */
  150.  
  151. extern void     double_to_decimal();
  152. extern void     quadruple_to_decimal();
  153. extern char    *econvert();
  154. extern char    *fconvert();
  155. extern char    *gconvert();
  156. extern char    *qeconvert();
  157. extern char    *qfconvert();
  158. extern char    *qgconvert();
  159.  
  160. /*
  161.     The following are used for other parts of base conversion.
  162. */
  163.  
  164. extern sigfpe_handler_type ieee_handlers[N_IEEE_EXCEPTION];
  165. /*
  166.  * Array of pointers to functions to handle SIGFPE's corresponding to IEEE
  167.  * fp_exceptions. sigfpe_default means do not generate SIGFPE. An invalid
  168.  * address such as sigfpe_abort will cause abort on that SIGFPE. Updated by
  169.  * ieee_handler.
  170.  */
  171.  
  172. extern sigfpe_handler_type sigfpe();
  173.  
  174. extern void     single_to_decimal();
  175. extern void     extended_to_decimal();
  176.  
  177. extern void     decimal_to_single();
  178. extern void     decimal_to_double();
  179. extern void     decimal_to_extended();
  180. extern void     decimal_to_quadruple();
  181.  
  182. extern char    *seconvert();
  183. extern char    *sfconvert();
  184. extern char    *sgconvert();
  185.  
  186. extern void     string_to_decimal();
  187. extern void     file_to_decimal();
  188. extern void     func_to_decimal();
  189.  
  190. /* Definitions from 4.3 BSD math.h  4.6  9/11/85         */
  191.  
  192. extern double   atof();
  193.  
  194. /* Definitions from System V                 */
  195.  
  196. extern int      errno;
  197.  
  198. extern double   strtod();
  199.  
  200. #endif                /* !_floatingpoint_h */
  201.