Deleted Added
full compact
gethex.c (187808) gethex.c (219557)
1/****************************************************************
2
3The author of this software is David M. Gay.
4
5Copyright (C) 1998 by Lucent Technologies
6All Rights Reserved
7
8Permission to use, copy, modify, and distribute this software and

--- 43 unchanged lines hidden (view full) ---

52 int i;
53#ifdef NO_LOCALE_CACHE
54 const unsigned char *decimalpoint = (unsigned char*)localeconv()->decimal_point;
55#else
56 const unsigned char *decimalpoint;
57 static unsigned char *decimalpoint_cache;
58 if (!(s0 = decimalpoint_cache)) {
59 s0 = (unsigned char*)localeconv()->decimal_point;
1/****************************************************************
2
3The author of this software is David M. Gay.
4
5Copyright (C) 1998 by Lucent Technologies
6All Rights Reserved
7
8Permission to use, copy, modify, and distribute this software and

--- 43 unchanged lines hidden (view full) ---

52 int i;
53#ifdef NO_LOCALE_CACHE
54 const unsigned char *decimalpoint = (unsigned char*)localeconv()->decimal_point;
55#else
56 const unsigned char *decimalpoint;
57 static unsigned char *decimalpoint_cache;
58 if (!(s0 = decimalpoint_cache)) {
59 s0 = (unsigned char*)localeconv()->decimal_point;
60 if ((decimalpoint_cache = (char*)malloc(strlen(s0) + 1))) {
60 if ((decimalpoint_cache = (char*)MALLOC(strlen(s0) + 1))) {
61 strcpy(decimalpoint_cache, s0);
62 s0 = decimalpoint_cache;
63 }
64 }
65 decimalpoint = s0;
66#endif
67#endif
68

--- 125 unchanged lines hidden (view full) ---

194 for(j = 0; j < n0; ++j)
195 b->x[j] = ALL_ON;
196 if (n > n0)
197 b->x[j] = ULbits >> (ULbits - (nbits & kmask));
198 *exp = fpi->emin;
199 return STRTOG_Normal | STRTOG_Inexlo;
200 }
201 n = s1 - s0 - 1;
61 strcpy(decimalpoint_cache, s0);
62 s0 = decimalpoint_cache;
63 }
64 }
65 decimalpoint = s0;
66#endif
67#endif
68

--- 125 unchanged lines hidden (view full) ---

194 for(j = 0; j < n0; ++j)
195 b->x[j] = ALL_ON;
196 if (n > n0)
197 b->x[j] = ULbits >> (ULbits - (nbits & kmask));
198 *exp = fpi->emin;
199 return STRTOG_Normal | STRTOG_Inexlo;
200 }
201 n = s1 - s0 - 1;
202 for(k = 0; n > (1 << kshift-2) - 1; n >>= 1)
202 for(k = 0; n > (1 << (kshift-2)) - 1; n >>= 1)
203 k++;
204 b = Balloc(k);
205 x = b->x;
206 n = 0;
207 L = 0;
208#ifdef USE_LOCALE
209 for(i = 0; decimalpoint[i+1]; ++i);
210#endif

--- 98 unchanged lines hidden (view full) ---

309 }
310 if (lostbits) {
311 up = 0;
312 switch(fpi->rounding) {
313 case FPI_Round_zero:
314 break;
315 case FPI_Round_near:
316 if (lostbits & 2
203 k++;
204 b = Balloc(k);
205 x = b->x;
206 n = 0;
207 L = 0;
208#ifdef USE_LOCALE
209 for(i = 0; decimalpoint[i+1]; ++i);
210#endif

--- 98 unchanged lines hidden (view full) ---

309 }
310 if (lostbits) {
311 up = 0;
312 switch(fpi->rounding) {
313 case FPI_Round_zero:
314 break;
315 case FPI_Round_near:
316 if (lostbits & 2
317 && (lostbits & 1) | x[0] & 1)
317 && (lostbits | x[0]) & 1)
318 up = 1;
319 break;
320 case FPI_Round_up:
321 up = 1 - sign;
322 break;
323 case FPI_Round_down:
324 up = sign;
325 }
326 if (up) {
327 k = b->wds;
328 b = increment(b);
329 x = b->x;
330 if (irv == STRTOG_Denormal) {
331 if (nbits == fpi->nbits - 1
332 && x[nbits >> kshift] & 1 << (nbits & kmask))
333 irv = STRTOG_Normal;
334 }
335 else if (b->wds > k
318 up = 1;
319 break;
320 case FPI_Round_up:
321 up = 1 - sign;
322 break;
323 case FPI_Round_down:
324 up = sign;
325 }
326 if (up) {
327 k = b->wds;
328 b = increment(b);
329 x = b->x;
330 if (irv == STRTOG_Denormal) {
331 if (nbits == fpi->nbits - 1
332 && x[nbits >> kshift] & 1 << (nbits & kmask))
333 irv = STRTOG_Normal;
334 }
335 else if (b->wds > k
336 || (n = nbits & kmask) !=0
337 && hi0bits(x[k-1]) < 32-n) {
336 || ((n = nbits & kmask) !=0
337 && hi0bits(x[k-1]) < 32-n)) {
338 rshift(b,1);
339 if (++e > fpi->emax)
340 goto ovfl;
341 }
342 irv |= STRTOG_Inexhi;
343 }
344 else
345 irv |= STRTOG_Inexlo;
346 }
347 *bp = b;
348 *exp = e;
349 return irv;
350 }
338 rshift(b,1);
339 if (++e > fpi->emax)
340 goto ovfl;
341 }
342 irv |= STRTOG_Inexhi;
343 }
344 else
345 irv |= STRTOG_Inexlo;
346 }
347 *bp = b;
348 *exp = e;
349 return irv;
350 }