From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFA] convert_doublest_to_floatformat: handle off-range values.
Date: Thu, 14 Jun 2012 00:51:00 -0000 [thread overview]
Message-ID: <20120614005043.GJ18729@adacore.com> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2012-06-14 0:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-14 0:01 Joel Brobecker
2012-06-14 0:51 ` Joel Brobecker [this message]
2012-07-25 18:31 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120614005043.GJ18729@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox