+2002-09-29 Richard Henderson <rth@redhat.com>
+
+ * real.c (real_from_string): Apply sign last. Tidy exponent handling.
+
2002-09-29 Richard Henderson <rth@redhat.com>
* combine.c (force_to_mode): Handle FLOAT_MODE destinations
const char *str;
{
int exp = 0;
+ bool sign = false;
get_zero (r, 0);
if (*str == '-')
{
- r->sign = 1;
+ sign = true;
str++;
}
else if (*str == '+')
if (*str == '.')
{
str++;
+ if (pos == SIGNIFICAND_BITS - 4)
+ {
+ while (*str == '0')
+ str++, exp -= 4;
+ }
while (1)
{
d = hex_value (*str);
}
if (*str == 'p' || *str == 'P')
{
- int exp_neg = 0;
+ bool exp_neg = false;
str++;
if (*str == '-')
{
- exp_neg = 1;
+ exp_neg = true;
str++;
}
else if (*str == '+')
d = 0;
while (ISDIGIT (*str))
{
- int t = d;
d *= 10;
d += *str - '0';
- if (d < t)
+ if (d > MAX_EXP)
{
/* Overflowed the exponent. */
if (exp_neg)
r->class = rvc_normal;
r->exp = exp;
- if (r->exp != exp)
- {
- if (exp < 0)
- goto underflow;
- else
- goto overflow;
- }
normalize (r);
}
if (*str == '.')
{
str++;
+ if (r->class == rvc_zero)
+ {
+ while (*str == '0')
+ str++, exp--;
+ }
while (ISDIGIT (*str))
{
d = *str++ - '0';
if (*str == 'e' || *str == 'E')
{
- int exp_neg = 0;
+ bool exp_neg = false;
str++;
if (*str == '-')
{
- exp_neg = 1;
+ exp_neg = true;
str++;
}
else if (*str == '+')
d = 0;
while (ISDIGIT (*str))
{
- int t = d;
d *= 10;
d += *str - '0';
- if (d < t)
+ if (d > MAX_EXP)
{
/* Overflowed the exponent. */
if (exp_neg)
}
}
+ r->sign = sign;
return;
underflow:
- get_zero (r, r->sign);
+ get_zero (r, sign);
return;
overflow:
- get_inf (r, r->sign);
+ get_inf (r, sign);
return;
}