public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bosch at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/18099] New: Incorrect rounding from floating point to integer Date: Thu, 21 Oct 2004 17:01:00 -0000 [thread overview] Message-ID: <20041021170112.18099.bosch@gcc.gnu.org> (raw) Ada requires conversion of floating-point to integer to round, with halfway cases rounded away from zero. This is implemented by adding 0.5 to the floating-point value and then truncating, as in regular C float to int conversion. However, this gives wrong semantics for the predecessor of 0.5, and odd floating-point integers in the range 2.0**(mantissa - 1)+1.0 .. 2.0**(mantissa)-1.0 and the negative versions of these. The reason is that adding 0.5 in the above cases, yields a value exactly between two representable floating-point numbers. So the predecessor of 0.5 is then rounded to one, and the floating-point integers mentioned before get rounded to the next higher integer. I'll file a self-contained test case testing these cases. -- Summary: Incorrect rounding from floating point to integer Product: gcc Version: 3.4.3 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: ada AssignedTo: bosch at gcc dot gnu dot org ReportedBy: bosch at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18099
next reply other threads:[~2004-10-21 17:01 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-10-21 17:01 bosch at gcc dot gnu dot org [this message] 2004-10-21 17:04 ` [Bug ada/18099] " bosch at gcc dot gnu dot org 2004-10-21 17:06 ` bosch at gcc dot gnu dot org 2005-02-24 22:37 ` bosch at gcc dot gnu dot org
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=20041021170112.18099.bosch@gcc.gnu.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).