Bug 88513 - GNAT 3.2: Bad results for math / numeric functions (sin, cos etc.)
Summary: GNAT 3.2: Bad results for math / numeric functions (sin, cos etc.)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc3
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-04-10 16:32 UTC by Andrew Lynch
Modified: 2007-04-18 16:52 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-10-03 21:43:09 UTC
Embargoed:


Attachments (Terms of Use)

Description Andrew Lynch 2003-04-10 16:32:42 UTC
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):
gcc-gnat-3.2-7
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;
begin
  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:
./mathproblem
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 21:43:09 UTC
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.