comp.lang.ada
 help / color / mirror / Atom feed
* GNAT Ada.Numerics.Aux question
@ 2003-07-29  3:17 Happy Segfault
  2003-07-29  5:06 ` Anders Wirzenius
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Happy Segfault @ 2003-07-29  3:17 UTC (permalink / raw)


Hi all!  

I'm trying out GtkAda 2.2.0 on my Red Hat 9 system using gcc 3.2.2,
and the testgtk OpenGL demo crashes with a constraint error.  I think
I've tracked down the problem to a call to Ada.Numerics.Aux.Sin, which
is a thin binding to the libm sin function.  What could be going wrong
here?  Why isn't Sin (X) getting the expected value in the program
below?  Oddly, Sqrt (X) seems to work fine.

--
-- test_sin.adb
--
with Ada.Text_IO;
with Ada.Numerics.Aux;
 
procedure test_sin is
  X : Ada.Numerics.Aux.Double;
begin
  X := Ada.Numerics.Aux.Double (2.0);
  X := Ada.Numerics.Aux.Sqrt (X);
  Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
  -- output is ' 1.41421356237309505E+00' which is expected
  X := Ada.Numerics.Aux.Double (30.0 * 3.14159 / 180.0);
  X := Ada.Numerics.Aux.Sin (X);
  -- use the pragma Import (C, Sin, "sin"); from Ada.Numerics.Aux
  Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
  -- output is '0.E+17' but 0.5 is the expected result
  Ada.Text_IO.Put_Line (Float'Image (Float (X)));
  -- raises constraint error
end test_sin;

Thanks!  

John



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-07-29 20:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29  3:17 GNAT Ada.Numerics.Aux question Happy Segfault
2003-07-29  5:06 ` Anders Wirzenius
2003-07-29  5:17 ` arvids lemchens
2003-07-29  8:34   ` Preben Randhol
2003-07-29  8:37 ` Preben Randhol
2003-07-29 12:37   ` Happy Segfault
2003-07-29 12:51     ` Preben Randhol
2003-07-29 20:01 ` Gerald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox