Bug 88513 - GNAT 3.2: Bad results for math / numeric functions (sin, cos etc.)
GNAT 3.2: Bad results for math / numeric functions (sin, cos etc.)
Product: Red Hat Linux
Classification: Retired
Component: gcc3 (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2003-04-10 12:32 EDT by Andrew Lynch
Modified: 2007-04-18 12:52 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-03 17:43:09 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Andrew Lynch 2003-04-10 12:32:42 EDT
Description of problem:
The functions in Ada.Numerics.Generic_Elementary_Functions return bad results,
eg. sin PI/2 = 1.68353553615965E-4932. The actual value seems to depend on the
circumstances in which the code was compiled - on a different machine the value
was 1.57079632679490E+15 (ie. the input value but multiplied by 1E+15)

Version-Release number of selected component (if applicable):
GNATMAKE 3.2 20020903 (3.2-7)

How reproducible:
-- Start simple Ada program
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Text_IO;

procedure MathProblem is
  package MyMath is new Ada.Numerics.Generic_Elementary_Functions(long_float);
  x, y : long_float := 0.0;
  x := Ada.Numerics.Pi / 2.0;
  Ada.Text_IO.Put_Line("x = " & long_float'Image(x));
  y := MyMath.Sin(x);
  Ada.Text_IO.Put_Line("sin(x) = " & long_float'Image(y));
end MathProblem;
-- End simple Ada program

Steps to Reproduce:
1. Save above code in mathproblem.adb
2. Run gnatmake -v mathproblem
3. Run ./mathproblem
Actual results:
x =  1.57079632679490E+00
sin(x) = 1.68353553615965E-4932

Expected results:
sin(x) = 1.00000000000000E+00    (+/- some small delta obviously)

Additional info:
GNAT 3.2 on Solaris 8 prints sin(x) = 9.99999685041438E-01
GNAT 3.13p on RedHat 7.1 prints sin(x) = 9.99999999979986E-01

The GNAT 3.2 with RedHat 8.0 uses the "Machine Version" of package Ada.Numerics.Aux (a-numaux.ads)
whereas GNAT 3.2 on Solaris and GNAT 3.13p from RedHat 7.1 use the "C Library Version".
Comment 1 Richard Henderson 2004-10-03 17:43:09 EDT
With gcc 3.2.3-20, I see similar completely bogus results,
but things appear to be fixed with gcc 3.3.2-1.

Note You need to log in before you can comment on or make changes to this bug.