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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <floatingpoint.h>
38 #include <sys/types.h>
43 strtod(const char *cp
, char **ptr
)
48 fp_exception_field_type fs
;
49 enum decimal_string_form form
;
53 lc
= (__xpg6
& _C99SUSv3_recognize_hexfp
)? -1 : 0;
54 string_to_decimal((char **)&cp
, MAXINT
, lc
, &dr
, &form
, &pechar
);
57 if (form
== invalid_form
)
58 return (0.0); /* Shameful kluge for SVID's sake. */
61 #elif defined(__i386) || defined(__amd64)
64 #error Unknown architecture
67 __hex_to_double(&dr
, mr
.rd
, &x
, &fs
);
69 decimal_to_double(&x
, &mr
, &dr
, &fs
);
70 if (fs
& ((1 << fp_overflow
) | (1 << fp_underflow
)))
76 strtof(const char *cp
, char **ptr
)
81 fp_exception_field_type fs
;
82 enum decimal_string_form form
;
85 string_to_decimal((char **)&cp
, MAXINT
, -1, &dr
, &form
, &pechar
);
88 if (form
== invalid_form
)
92 #elif defined(__i386) || defined(__amd64)
95 #error Unknown architecture
98 __hex_to_single(&dr
, mr
.rd
, &x
, &fs
);
100 decimal_to_single(&x
, &mr
, &dr
, &fs
);
101 if (fs
& ((1 << fp_overflow
) | (1 << fp_underflow
)))
107 strtold(const char *cp
, char **ptr
)
112 fp_exception_field_type fs
;
113 enum decimal_string_form form
;
116 string_to_decimal((char **)&cp
, MAXINT
, -1, &dr
, &form
, &pechar
);
119 if (form
== invalid_form
)
124 __hex_to_quadruple(&dr
, mr
.rd
, &x
, &fs
);
126 decimal_to_quadruple(&x
, &mr
, &dr
, &fs
);
127 #elif defined(__i386) || defined(__amd64)
130 __hex_to_extended(&dr
, mr
.rd
, (extended
*)&x
, &fs
);
132 decimal_to_extended((extended
*)&x
, &mr
, &dr
, &fs
);
134 #error Unknown architecture
136 if (fs
& ((1 << fp_overflow
) | (1 << fp_underflow
)))