1 /****************************************************************
3 The author of this software is David M. Gay.
5 Copyright (C) 1998, 1999 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 "."). */
37 (s
, nd0
, nd
, y9
, dplen
) CONST
char *s
; int dplen
, nd0
, nd
; ULong y9
;
39 (CONST
char *s
, int nd0
, int nd
, ULong y9
, int dplen
)
47 for(k
= 0, y
= 1; x
> y
; y
<<= 1, k
++) ;
54 b
->x
[0] = y9
& 0xffff;
55 b
->wds
= (b
->x
[1] = y9
>> 16) ? 2 : 1;
61 do b
= multadd(b
, 10, *s
++ - '0');
68 b
= multadd(b
, 10, *s
++ - '0');
77 (Bigint
*a
, Bigint
*b
)
83 dval(da
) = b2d(a
, &ka
);
84 dval(db
) = b2d(b
, &kb
);
85 k
= ka
- kb
+ ULbits
*(a
->wds
- b
->wds
);
88 word0(da
) += (k
>> 2)*Exp_msk1
;
94 word0(db
) += (k
>> 2)*Exp_msk1
;
100 word0(da
) += k
*Exp_msk1
;
103 word0(db
) += k
*Exp_msk1
;
106 return dval(da
) / dval(db
);
114 (sp
, t
) char **sp
, *t
;
116 (CONST
char **sp
, char *t
)
122 while( (d
= *t
++) !=0) {
123 if ((c
= *++s
) >= 'A' && c
<= 'Z')
131 #endif /* INFNAN_CHECK */
135 copybits(c
, n
, b
) ULong
*c
; int n
; Bigint
*b
;
137 copybits(ULong
*c
, int n
, Bigint
*b
)
145 ce
= c
+ ((n
-1) >> kshift
) + 1;
154 for(xe
= x
+ (nw
- nw1
); x
< xe
; x
+= 2)
155 Storeinc(c
, x
[1], x
[0]);
165 any_on(b
, k
) Bigint
*b
; int k
;
167 any_on(Bigint
*b
, int k
)
171 ULong
*x
, *x0
, x1
, x2
;
178 else if (n
< nwds
&& (k
&= kmask
)) {