4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
21 /* Copyright (C) 1989 AT&T */
22 /* All Rights Reserved */
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
28 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
29 * Use is subject to license terms.
32 #ifndef _FLOATINGPOINT_H
33 #define _FLOATINGPOINT_H
36 #include <stdio_tag.h>
38 #include <sys/ieeefp.h>
45 * <floatingpoint.h> contains definitions for constants, types, variables,
47 * IEEE floating-point arithmetic base conversion;
48 * IEEE floating-point arithmetic modes;
49 * IEEE floating-point arithmetic exception handling.
58 #endif /* !defined(__P) */
60 #if defined(__STDC__) && !defined(_FILEDEFED)
65 #define N_IEEE_EXCEPTION 5 /* Number of floating-point exceptions. */
67 typedef int sigfpe_code_type
; /* Type of SIGFPE code. */
69 typedef void (*sigfpe_handler_type
)(); /* Pointer to exception handler */
71 #define SIGFPE_DEFAULT (void (*)())0 /* default exception handling */
72 #define SIGFPE_IGNORE (void (*)())1 /* ignore this exception or code */
73 #define SIGFPE_ABORT (void (*)())2 /* force abort on exception */
75 extern sigfpe_handler_type sigfpe
__P((sigfpe_code_type
, sigfpe_handler_type
));
78 * Types for IEEE floating point.
84 typedef unsigned extended
[3];
87 typedef long double quadruple
; /* Quadruple-precision type. */
89 typedef unsigned fp_exception_field_type
;
91 * A field containing fp_exceptions OR'ed
95 * Definitions for base conversion.
97 #define DECIMAL_STRING_LENGTH 512 /* Size of buffer in decimal_record. */
99 typedef char decimal_string
[DECIMAL_STRING_LENGTH
];
100 /* Decimal significand. */
103 enum fp_class_type fpclass
;
106 decimal_string ds
; /* Significand - each char contains an ascii */
107 /* digit, except the string-terminating */
109 int more
; /* On conversion from decimal to binary, != 0 */
110 /* indicates more non-zero digits following */
112 int ndigits
; /* On fixed_form conversion from binary to */
113 /* decimal, contains number of digits */
114 /* required for ds. */
118 fixed_form
, /* Fortran F format: ndigits specifies number */
119 /* of digits after point; if negative, */
120 /* specifies rounding to occur to left of */
122 floating_form
/* Fortran E format: ndigits specifies number */
123 /* of significant digits. */
127 enum fp_direction_type rd
;
128 /* Rounding direction. */
129 enum decimal_form df
; /* Format for conversion from binary to */
131 int ndigits
; /* Number of digits for conversion. */
134 enum decimal_string_form
{ /* Valid decimal number string formats. */
135 invalid_form
, /* Not a valid decimal string format. */
136 whitespace_form
, /* All white space - valid in Fortran! */
137 fixed_int_form
, /* <digs> */
138 fixed_intdot_form
, /* <digs>. */
139 fixed_dotfrac_form
, /* .<digs> */
140 fixed_intdotfrac_form
, /* <digs>.<frac> */
141 floating_int_form
, /* <digs><exp> */
142 floating_intdot_form
, /* <digs>.<exp> */
143 floating_dotfrac_form
, /* .<digs><exp> */
144 floating_intdotfrac_form
, /* <digs>.<digs><exp> */
146 infinity_form
, /* infinity */
148 nanstring_form
/* nan(string) */
151 extern void single_to_decimal
__P((single
*, decimal_mode
*, decimal_record
*,
152 fp_exception_field_type
*));
153 extern void double_to_decimal
__P((double *, decimal_mode
*, decimal_record
*,
154 fp_exception_field_type
*));
155 extern void extended_to_decimal
__P((extended
*, decimal_mode
*,
156 decimal_record
*, fp_exception_field_type
*));
157 extern void quadruple_to_decimal
__P((quadruple
*, decimal_mode
*,
158 decimal_record
*, fp_exception_field_type
*));
160 extern void decimal_to_single
__P((single
*, decimal_mode
*, decimal_record
*,
161 fp_exception_field_type
*));
162 extern void decimal_to_double
__P((double *, decimal_mode
*, decimal_record
*,
163 fp_exception_field_type
*));
164 extern void decimal_to_extended
__P((extended
*, decimal_mode
*,
165 decimal_record
*, fp_exception_field_type
*));
166 extern void decimal_to_quadruple
__P((quadruple
*, decimal_mode
*,
167 decimal_record
*, fp_exception_field_type
*));
169 extern void string_to_decimal
__P((char **, int, int, decimal_record
*,
170 enum decimal_string_form
*, char **));
171 extern void func_to_decimal
__P((char **, int, int, decimal_record
*,
172 enum decimal_string_form
*, char **,
173 int (*)(void), int *, int (*)(int)));
174 extern void file_to_decimal
__P((char **, int, int, decimal_record
*,
175 enum decimal_string_form
*, char **,
178 extern char *seconvert
__P((single
*, int, int *, int *, char *));
179 extern char *sfconvert
__P((single
*, int, int *, int *, char *));
180 extern char *sgconvert
__P((single
*, int, int, char *));
181 extern char *econvert
__P((double, int, int *, int *, char *));
182 extern char *fconvert
__P((double, int, int *, int *, char *));
183 extern char *gconvert
__P((double, int, int, char *));
184 extern char *qeconvert
__P((quadruple
*, int, int *, int *, char *));
185 extern char *qfconvert
__P((quadruple
*, int, int *, int *, char *));
186 extern char *qgconvert
__P((quadruple
*, int, int, char *));
188 extern char *ecvt
__P((double, int, int *, int *));
189 extern char *fcvt
__P((double, int, int *, int *));
190 extern char *gcvt
__P((double, int, char *));
192 #if __cplusplus >= 199711L
196 * ANSI C Standard says the following entry points should be
197 * prototyped in <stdlib.h>. They are now, but weren't before.
199 extern double atof
__P((const char *));
200 extern double strtod
__P((const char *, char **));
201 #if __cplusplus >= 199711L
206 #endif /* end of namespace std */
212 #endif /* _FLOATINGPOINT_H */