(emdnorm, eifrac, euifrac, mtherr): Replace
unconditional `pedwarn' by `warning' conditional on `extra_warnings'.
(toe24, todec): Use ERANGE to flag overflow on (non-IEEE)
machines that do not have infinity.
(etoasc): Check explicitly for overflow of leading decimal digit.
(asctoeg): Test for, and immediately reject, out-of-bounds
decimal exponent inputs.
(at top level): Include errno.h; reference errno, warning, extra_warnings.
From-SVN: r4300
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
+#ifndef errno
+extern int errno;
+#endif
+
/* To enable support of XFmode extended real floating point, define
LONG_DOUBLE_TYPE_SIZE 96 in the tm.h file (m68k.h or i386.h).
/* To enable support of XFmode extended real floating point, define
LONG_DOUBLE_TYPE_SIZE 96 in the tm.h file (m68k.h or i386.h).
#endif /* not REAL_ARITHMETIC */
#endif /* no XFmode */
#endif /* not REAL_ARITHMETIC */
#endif /* no XFmode */
+void warning ();
+extern int extra_warnings;
int ecmp (), enormlz (), eshift (), eisneg (), eisinf ();
void eadd (), esub (), emul (), ediv ();
void eshup1 (), eshup8 (), eshup6 (), eshdn1 (), eshdn8 (), eshdn6 ();
int ecmp (), enormlz (), eshift (), eisneg (), eisinf ();
void eadd (), esub (), emul (), ediv ();
void eshup1 (), eshup8 (), eshup6 (), eshdn1 (), eshdn8 (), eshdn6 ();
s[1] = 32767;
for (i = 2; i < NI - 1; i++)
s[i] = 0;
s[1] = 32767;
for (i = 2; i < NI - 1; i++)
s[i] = 0;
- pedwarn ("floating point overflow");
+ if (extra_warnings)
+ warning ("floating point overflow");
#else
s[1] = 32766;
s[2] = 0;
#else
s[1] = 32766;
s[2] = 0;
*p++ = *e++;
*p++ = *e++;
#endif
*p++ = *e++;
*p++ = *e++;
#endif
- (void) eshift (yy, -5);
if (denorm)
{ /* if zero exponent, then normalize the significand */
if ((k = enormlz (yy)) > NBITS)
if (denorm)
{ /* if zero exponent, then normalize the significand */
if ((k = enormlz (yy)) > NBITS)
- (void) eshift (yy, -8);
if (denorm)
{ /* if zero exponent, then normalize the significand */
if ((k = enormlz (yy)) > NBITS)
if (denorm)
{ /* if zero exponent, then normalize the significand */
if ((k = enormlz (yy)) > NBITS)
}
i |= *p++ & (unsigned EMUSHORT) 0x0f; /* *p = xi[M] */
*y |= (unsigned EMUSHORT) i; /* high order output already has sign bit set */
}
i |= *p++ & (unsigned EMUSHORT) 0x0f; /* *p = xi[M] */
*y |= (unsigned EMUSHORT) i; /* high order output already has sign bit set */
*y = 0x8000; /* output sign bit */
i = *p++;
*y = 0x8000; /* output sign bit */
i = *p++;
+/* Handle overflow cases. */
- { /* Saturate at largest number less than infinity. */
#ifdef INFINITY
*y |= (unsigned EMUSHORT) 0x7f80;
#ifdef IBMPC
#ifdef INFINITY
*y |= (unsigned EMUSHORT) 0x7f80;
#ifdef IBMPC
*y |= (unsigned EMUSHORT) 0x7f7f;
#ifdef IBMPC
*(--y) = 0xffff;
*y |= (unsigned EMUSHORT) 0x7f7f;
#ifdef IBMPC
*(--y) = 0xffff;
+#ifdef ERANGE
+ errno = ERANGE;
+#endif /* no INFINITY */
}
i |= *p++ & (unsigned EMUSHORT) 0x7f; /* *p = xi[M] */
*y |= i; /* high order output already has sign bit set */
}
i |= *p++ & (unsigned EMUSHORT) 0x7f; /* *p = xi[M] */
*y |= i; /* high order output already has sign bit set */
*i = ((unsigned long) 1) << (HOST_BITS_PER_LONG - 1);
else
*i = (((unsigned long) 1) << (HOST_BITS_PER_LONG - 1)) - 1;
*i = ((unsigned long) 1) << (HOST_BITS_PER_LONG - 1);
else
*i = (((unsigned long) 1) << (HOST_BITS_PER_LONG - 1)) - 1;
- (void) eshift (xi, k);
- pedwarn ("Overflow on truncation to integer");
+ eshift (xi, k);
+ if (extra_warnings)
+ warning ("overflow on truncation to integer");
; then complete the shift to get the fraction.
*/
k -= 16;
; then complete the shift to get the fraction.
*/
k -= 16;
*i = (long) (((unsigned long) xi[M] << 16) | xi[M + 1]);
eshup6 (xi);
*i = (long) (((unsigned long) xi[M] << 16) | xi[M + 1]);
eshup6 (xi);
}
/* shift not more than 16 bits */
}
/* shift not more than 16 bits */
*i = (long) xi[M] & 0xffff;
lab10:
*i = (long) xi[M] & 0xffff;
lab10:
; and correct fraction
*/
*i = ~(0L);
; and correct fraction
*/
*i = ~(0L);
- (void) eshift (xi, k);
- pedwarn ("Overflow on truncation to unsigned integer");
+ eshift (xi, k);
+ if (extra_warnings)
+ warning ("overflow on truncation to unsigned integer");
; then complete the shift to get the fraction.
*/
k -= 16;
; then complete the shift to get the fraction.
*/
k -= 16;
*i = (long) (((unsigned long) xi[M] << 16) | xi[M + 1]);
eshup6 (xi);
*i = (long) (((unsigned long) xi[M] << 16) | xi[M + 1]);
eshup6 (xi);
}
/* shift not more than 16 bits */
}
/* shift not more than 16 bits */
*i = (long) xi[M] & 0xffff;
lab10:
*i = (long) xi[M] & 0xffff;
lab10:
*s++ = '-';
else
*s++ = ' ';
*s++ = '-';
else
*s++ = ' ';
- *s++ = (char) digit + '0';
- *s++ = '.';
/* Examine number of digits requested by caller. */
if (ndigs < 0)
ndigs = 0;
if (ndigs > NDEC)
ndigs = NDEC;
/* Examine number of digits requested by caller. */
if (ndigs < 0)
ndigs = 0;
if (ndigs > NDEC)
ndigs = NDEC;
+ if (digit == 10)
+ {
+ *s++ = '1';
+ *s++ = '.';
+ if (ndigs > 0)
+ {
+ *s++ = '0';
+ ndigs -= 1;
+ }
+ expon += 1;
+ }
+ else
+ {
+ *s++ = (char )digit + '0';
+ *s++ = '.';
+ }
/* Generate digits after the decimal point. */
for (k = 0; k <= ndigs; k++)
{
/* Generate digits after the decimal point. */
for (k = 0; k <= ndigs; k++)
{
goto daldone;
case 'i':
case 'I':
goto daldone;
case 'i':
case 'I':
- ecleaz (yy);
- yy[E] = 0x7fff; /* infinity */
- goto aexit;
default:
error:
mtherr ("asctoe", DOMAIN);
default:
error:
mtherr ("asctoe", DOMAIN);
{
exp *= 10;
exp += *s++ - '0';
{
exp *= 10;
exp += *s++ - '0';
+ if (exp > 4956)
+ {
+ if (esign < 0)
+ goto zero;
+ else
+ goto infinite;
+ }
}
if (esign < 0)
exp = -exp;
}
if (esign < 0)
exp = -exp;
+ if (exp > 4932)
+ {
+ infinite:
+ ecleaz (yy);
+ yy[E] = 0x7fff; /* infinity */
+ goto aexit;
+ }
+ if (exp < -4956)
+ {
+ zero:
+ ecleaz (yy);
+ goto aexit;
+ }
daldone:
nexp = exp - nexp;
daldone:
nexp = exp - nexp;
if ((code <= 0) || (code >= 6))
code = 0;
sprintf (errstr, "\n%s %s error\n", name, ermsg[code]);
if ((code <= 0) || (code >= 6))
code = 0;
sprintf (errstr, "\n%s %s error\n", name, ermsg[code]);
+ if (extra_warnings)
+ warning (errstr);
/* Set global error message word */
merror = code + 1;
/* Set global error message word */
merror = code + 1;
*y++ = 0xffff;
*y++ = 0xffff;
*y++ = 0xffff;
*y++ = 0xffff;
*y++ = 0xffff;
*y++ = 0xffff;
+#ifdef ERANGE
+ errno = ERANGE;
+#endif