]>
git.saurik.com Git - apple/libc.git/blob - gdtoa/FreeBSD/gdtoa-strtoIg.c
1 /****************************************************************
3 The author of this software is David M. Gay.
5 Copyright (C) 1998 by Lucent Technologies
8 Permission to use, copy, modify, and distribute this software and
9 its documentation for any purpose and without fee is hereby
10 granted, provided that the above copyright notice appear in all
11 copies and that both that the copyright notice and this
12 permission notice and warranty disclaimer appear in supporting
13 documentation, and that the name of Lucent or any of its entities
14 not be used in advertising or publicity pertaining to
15 distribution of the software without specific, written prior
18 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
20 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27 ****************************************************************/
29 /* Please send bug reports to David M. Gay (dmg at acm dot org,
30 * with " at " changed at "@" and " dot " changed to "."). */
36 strtoIg(s00
, se
, fpi
, exp
, B
, rvp
) CONST
char *s00
; char **se
; FPI
*fpi
; Long
*exp
; Bigint
**B
; int *rvp
;
38 strtoIg(CONST
char *s00
, char **se
, FPI
*fpi
, Long
*exp
, Bigint
**B
, int *rvp
)
42 int i
, nb
, nw
, nw1
, rv
, rv1
, swap
;
43 unsigned int nb1
, nb11
;
47 rv
= strtodg(s00
, se
, fpi
, exp
, b
->x
);
48 if (!(rv
& STRTOG_Inexact
)) {
53 rv1
= rv
^ STRTOG_Inexact
;
58 nb11
= (nb1
- 1) & 31;
61 if (rv
& STRTOG_Inexlo
) {
64 if (fpi
->sudden_underflow
65 && (rv
& STRTOG_Retmask
) == STRTOG_Zero
) {
67 b1
->x
[nw1
] = 1L << nb11
;
68 rv1
+= STRTOG_Normal
- STRTOG_Zero
;
69 rv1
&= ~STRTOG_Underflow
;
73 || nb1
&& b1
->x
[nw1
] & 1L << nb1
) {
75 rv1
= STRTOG_Infinite
| STRTOG_Inexhi
;
78 else if ((rv
& STRTOG_Retmask
) == STRTOG_Denormal
) {
79 if (b1
->x
[nw1
] & 1L << nb11
) {
80 rv1
+= STRTOG_Normal
- STRTOG_Denormal
;
81 rv1
&= ~STRTOG_Underflow
;
87 if ((rv
& STRTOG_Retmask
) == STRTOG_Infinite
) {
88 b1
= set_ones(b1
, nb
);
90 rv1
= STRTOG_Normal
| STRTOG_Inexlo
;
94 if ((rv
& STRTOG_Retmask
) == STRTOG_Denormal
) {
95 for(i
= nw1
; !b1
->x
[i
]; --i
)
97 rv1
= STRTOG_Zero
| STRTOG_Inexlo
;
102 if (!(b1
->x
[nw1
] & 1L << nb11
)) {
103 if (e1
== fpi
->emin
) {
104 if (fpi
->sudden_underflow
)
105 rv1
+= STRTOG_Zero
- STRTOG_Normal
;
107 rv1
+= STRTOG_Denormal
- STRTOG_Normal
;
108 rv1
|= STRTOG_Underflow
;
118 if (swap
^ (rv
& STRTOG_Neg
)) {