From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7143 invoked by alias); 21 Oct 2004 17:01:15 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7126 invoked by uid 48); 21 Oct 2004 17:01:14 -0000 Date: Thu, 21 Oct 2004 17:01:00 -0000 From: "bosch at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20041021170112.18099.bosch@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug ada/18099] New: Incorrect rounding from floating point to integer X-Bugzilla-Reason: CC X-SW-Source: 2004-10/txt/msg02790.txt.bz2 List-Id: 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