]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/gdtoa/smisc.c
1 /* $NetBSD: smisc.c,v 1.2.14.1 2008/04/08 21:10:55 jdc Exp $ */
3 /****************************************************************
5 The author of this software is David M. Gay.
7 Copyright (C) 1998, 1999 by Lucent Technologies
10 Permission to use, copy, modify, and distribute this software and
11 its documentation for any purpose and without fee is hereby
12 granted, provided that the above copyright notice appear in all
13 copies and that both that the copyright notice and this
14 permission notice and warranty disclaimer appear in supporting
15 documentation, and that the name of Lucent or any of its entities
16 not be used in advertising or publicity pertaining to
17 distribution of the software without specific, written prior
20 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
21 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
22 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
23 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
25 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
29 ****************************************************************/
31 /* Please send bug reports to David M. Gay (dmg at acm dot org,
32 * with " at " changed at "@" and " dot " changed to "."). */
33 #include <LibConfig.h>
37 #if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
38 // Disable: warning C4700: uninitialized local variable 'xx' used
39 #pragma warning ( disable : 4700 )
40 #endif /* defined(_MSC_VER) */
45 (s
, nd0
, nd
, y9
) CONST
char *s
; int nd0
, nd
; ULong y9
;
47 (CONST
char *s
, int nd0
, int nd
, ULong y9
)
55 for(k
= 0, y
= 1; x
> y
; y
<<= 1, k
++) ;
66 b
->x
[0] = y9
& 0xffff;
67 b
->wds
= (b
->x
[1] = y9
>> 16) ? 2 : 1;
74 b
= multadd(b
, 10, *s
++ - '0');
83 b
= multadd(b
, 10, *s
++ - '0');
95 (Bigint
*a
, Bigint
*b
)
101 dval(da
) = b2d(a
, &ka
);
102 dval(db
) = b2d(b
, &kb
);
103 k
= ka
- kb
+ ULbits
*(a
->wds
- b
->wds
);
106 word0(da
) += (k
>> 2)*Exp_msk1
;
112 word0(db
) += (k
>> 2)*Exp_msk1
;
118 word0(da
) += k
*Exp_msk1
;
121 word0(db
) += k
*Exp_msk1
;
124 return dval(da
) / dval(db
);
132 (sp
, t
) CONST
char **sp
, *t
;
134 (CONST
char **sp
, CONST
char *t
)
140 while( (d
= *t
++) !=0) {
141 if ((c
= *++s
) >= 'A' && c
<= 'Z')
149 #endif /* INFNAN_CHECK */
153 copybits(c
, n
, b
) ULong
*c
; int n
; Bigint
*b
;
155 copybits(ULong
*c
, int n
, Bigint
*b
)
163 ce
= c
+ ((unsigned int)(n
-1) >> kshift
) + 1;
172 for(xe
= x
+ (nw
- nw1
); x
< xe
; x
+= 2)
173 Storeinc(c
, x
[1], x
[0]);
183 any_on(b
, k
) Bigint
*b
; int k
;
185 any_on(Bigint
*b
, int k
)
189 ULong
*x
, *x0
, x1
, x2
;
193 n
= (unsigned int)k
>> kshift
;
196 else if (n
< nwds
&& (k
&= kmask
)) {