1 /* $NetBSD: strtodnrp.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
3 /****************************************************************
5 The author of this software is David M. Gay.
7 Copyright (C) 2004 by David M. Gay.
9 Based on material in the rest of /netlib/fp/gdota.tar.gz,
10 which is copyright (C) 1998, 2000 by Lucent Technologies.
12 Permission to use, copy, modify, and distribute this software and
13 its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of Lucent or any of its entities
18 not be used in advertising or publicity pertaining to
19 distribution of the software without specific, written prior
22 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
23 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
24 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
25 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
27 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
31 ****************************************************************/
33 /* This is a variant of strtod that works on Intel ia32 systems */
34 /* with the default extended-precision arithmetic -- it does not */
35 /* require setting the precision control to 53 bits. */
37 /* Please send bug reports to David M. Gay (dmg at acm dot org,
38 * with " at " changed at "@" and " dot " changed to "."). */
44 strtod(s
, sp
) CONST
char *s
; char **sp
;
46 strtod(CONST
char *s
, char **sp
)
49 static const FPI fpi
= { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI
};
53 union { ULong L
[2]; double d
; } u
;
55 k
= strtodg(s
, sp
, &fpi
, &expt
, bits
);
56 if (k
== STRTOG_NoMemory
) {
62 switch(k
& STRTOG_Retmask
) {
70 u
.L
[_0
] = (bits
[1] & ~0x100000) | ((expt
+ 0x3ff + 52) << 20);
89 u
.L
[_0
] = 0x7ff00000 | bits
[1];
93 u
.L
[_0
] |= 0x80000000L
;