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 ((rv
& STRTOG_Retmask
) == STRTOG_Zero
) {
65 if (fpi
->sudden_underflow
) {
67 b1
->x
[nw1
] = 1L << nb11
;
68 rv1
+= STRTOG_Normal
- STRTOG_Zero
;
69 rv1
&= ~STRTOG_Underflow
;
72 rv1
&= STRTOG_Inexlo
| STRTOG_Underflow
| STRTOG_Zero
;
73 rv1
|= STRTOG_Inexhi
| STRTOG_Denormal
;
77 || nb1
&& b1
->x
[nw1
] & 1L << nb1
) {
79 rv1
= STRTOG_Infinite
| STRTOG_Inexhi
;
82 else if ((rv
& STRTOG_Retmask
) == STRTOG_Denormal
) {
83 if (b1
->x
[nw1
] & 1L << nb11
) {
84 rv1
+= STRTOG_Normal
- STRTOG_Denormal
;
85 rv1
&= ~STRTOG_Underflow
;
91 if ((rv
& STRTOG_Retmask
) == STRTOG_Infinite
) {
92 b1
= set_ones(b1
, nb
);
94 rv1
= STRTOG_Normal
| STRTOG_Inexlo
;
98 if ((rv
& STRTOG_Retmask
) == STRTOG_Denormal
) {
99 for(i
= nw1
; !b1
->x
[i
]; --i
)
101 rv1
= STRTOG_Zero
| STRTOG_Inexlo
;
106 if (!(b1
->x
[nw1
] & 1L << nb11
)) {
107 if (e1
== fpi
->emin
) {
108 if (fpi
->sudden_underflow
)
109 rv1
+= STRTOG_Zero
- STRTOG_Normal
;
111 rv1
+= STRTOG_Denormal
- STRTOG_Normal
;
112 rv1
|= STRTOG_Underflow
;
122 if (swap
^ (rv
& STRTOG_Neg
)) {