From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [Ada] Correctly round Value attribute for floating point in more cases
Date: Tue, 6 Sep 2022 09:15:39 +0200 [thread overview]
Message-ID: <20220906071539.GA1280171@poulhies-Precision-5550> (raw)
[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]
This provides correct rounding in the IEEE 754 sense for the Value attribute
of floating-point types in more cases, by bumping the number of significant
bits used in the initial integer mantissa obtained from parsing.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnat/s-valuer.ads (System.Value_R): Add Parts formal parameter
as well as Data_Index, Scale_Array and Value_Array types.
(Scan_Raw_Real): Change type of Scale and return type.
(Value_Raw_Real): Likewise.
* libgnat/s-valuer.adb (Round_Extra): Reorder parameters and adjust
recursive call.
(Scan_Decimal_Digits): Reorder parameters, add N parameter and deal
with multi-part scale and value.
(Scan_Integral_Digits): Likewise.
(Scan_Raw_Real): Change type of Scale and return type and deal with
multi-part scale and value.
(Value_Raw_Real): Change type of Scale and return type and tidy up.
* libgnat/s-valued.adb (Impl): Pass 1 as Parts actual parameter.
(Scan_Decimal): Adjust to type changes.
(Value_Decimal): Likewise.
* libgnat/s-valuef.adb (Impl): Pass 1 as Parts actual parameter.
(Scan_Fixed): Adjust to type changes.
(Value_Fixed): Likewise.
* libgnat/s-valrea.adb (Need_Extra): Delete.
(Precision_Limit): Always use the precision of the mantissa.
(Impl): Pass 2 as Parts actual parameter.
(Exact_Log2): New expression function.
(Integer_to_Real): Change type of Scale and Val and deal with a
2-part integer mantissa.
(Scan_Real): Adjust to type changes.
(Value_Real): Likewise.
[-- Attachment #2: patch.diff.gz --]
[-- Type: application/gzip, Size: 6647 bytes --]
next reply other threads:[~2022-09-06 7:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 7:15 Marc Poulhiès [this message]
2022-09-06 7:15 Marc Poulhiès
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=20220906071539.GA1280171@poulhies-Precision-5550 \
--to=poulhies@adacore.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).