This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] convert_doublest_to_floatformat: handle off-range values.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 13 Jun 2012 17:50:43 -0700
- Subject: Re: [RFA] convert_doublest_to_floatformat: handle off-range values.
- References: <1339632037-5252-1-git-send-email-brobecker@adacore.com>
> + if (exponent + fmt->exp_bias <= 0)
> + {
> + /* The value is too small to be expressed in the destination
> + type (not enough bits in the exponent. Treat as 0. */
> + put_field (uto, order, fmt->totalsize, fmt->exp_start,
> + fmt->exp_len, 0);
> + put_field (uto, order, fmt->totalsize, fmt->man_start,
> + fmt->man_len, 0);
> + goto finalize_byteorder;
> + }
For these small numbers, we could do like libiberty, and generate
denormalized numbers, like so:
if (exponent + fmt->exp_bias - 1 > 0)
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
fmt->exp_len, exponent + fmt->exp_bias - 1);
else
{
/* Handle a denormalized number. FIXME: What should we do for
non-IEEE formats? */
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
fmt->exp_len, 0);
mant = ldexp (mant, exponent + fmt->exp_bias - 1);
}
But it'd be a larger change, because we'd have to write a portable
version of ldexp that works for "long double". Actually, we could
import ldexp and ldexpl.
We should probably also consider the import of frexp and frexpl
as well. It'd allow us to get rid of our own implementation.
--
Joel