BlockContext's caller is now stored in sender field
[panda.git] / libs / libgdtoa / strtorf.c
blob21c6d28b88b904460ebe961e3efd7af66f76ed51
1 /****************************************************************
3 The author of this software is David M. Gay.
5 Copyright (C) 1998, 2000 by Lucent Technologies
6 All Rights Reserved
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
16 permission.
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
25 THIS SOFTWARE.
27 ****************************************************************/
29 /* Please send bug reports to David M. Gay (dmg at acm dot org,
30 * with " at " changed at "@" and " dot " changed to "."). */
32 #include "gdtoaimp.h"
34 void
35 #ifdef KR_headers
36 ULtof(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
37 #else
38 ULtof(ULong *L, ULong *bits, Long exp, int k)
39 #endif
41 switch(k & STRTOG_Retmask) {
42 case STRTOG_NoNumber:
43 case STRTOG_Zero:
44 *L = 0;
45 break;
47 case STRTOG_Normal:
48 case STRTOG_NaNbits:
49 L[0] = (bits[0] & 0x7fffff) | ((exp + 0x7f + 23) << 23);
50 break;
52 case STRTOG_Denormal:
53 L[0] = bits[0];
54 break;
56 case STRTOG_Infinite:
57 L[0] = 0x7f800000;
58 break;
60 case STRTOG_NaN:
61 L[0] = f_QNAN;
63 if (k & STRTOG_Neg)
64 L[0] |= 0x80000000L;
67 int
68 #ifdef KR_headers
69 strtorf(s, sp, rounding, f) CONST char *s; char **sp; int rounding; float *f;
70 #else
71 strtorf(CONST char *s, char **sp, int rounding, float *f)
72 #endif
74 static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
75 FPI *fpi, fpi1;
76 ULong bits[1];
77 Long exp;
78 int k;
80 fpi = &fpi0;
81 if (rounding != FPI_Round_near) {
82 fpi1 = fpi0;
83 fpi1.rounding = rounding;
84 fpi = &fpi1;
86 k = strtodg(s, sp, fpi, &exp, bits);
87 ULtof((ULong*)f, bits, exp, k);
88 return k;