comp.lang.ada
 help / color / mirror / Atom feed
* Assignment of small Float values
@ 2000-04-17  0:00 David W. Glessner
  2000-04-29  0:00 ` swhalen
  2000-05-02  0:00 ` Disturbing float conversions jboulais
  0 siblings, 2 replies; 7+ messages in thread
From: David W. Glessner @ 2000-04-17  0:00 UTC (permalink / raw)


Why does GNAT treat the non-zero constant as 0.0 in the assignment to
F1 in the following example?  32-bit IEEE floating-point should
support values down to around 10**-38 (and even down to 10**-45 or
so for subnormal numbers).

Note that Rational Apex Ada behaves as I expected.

Is there something in Ada that allows the assignment of 0.0 or is
this a GNAT bug?


-- Test program that shows unexplained (to me at least) GNAT behavior
for
-- floating point assignments.
--
-- GNAT 3.12p Win98 displays:
-- 0.00000E+00                           <-- Why does GNAT display 0.0?
-- 6.66666666666667E-33
-- 6.66667E-33
--
-- Rational Apex 3.0.0b for Solaris (Sparc) displays:
-- 6.66667E-33
-- 6.66666666666667E-33
-- 6.66667E-33
with Ada.Text_Io;
procedure Test_Float_Range is
    C : constant := 6.6666666666666666E-33;
    F1 : Float := C;
    F2 : Long_Float := C;
    F3 : Float := Float (F2);
    use Ada.Text_Io;
begin
    Put_Line (Float'Image (F1));
    Put_Line (Long_Float'Image (F2));
    Put_Line (Float'Image (F3));
end Test_Float_Range;


Sent via Deja.com http://www.deja.com/
Before you buy.




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

end of thread, other threads:[~2000-05-13  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-17  0:00 Assignment of small Float values David W. Glessner
2000-04-29  0:00 ` swhalen
2000-04-30  0:00   ` Robert I. Eachus
2000-05-02  0:00 ` Disturbing float conversions jboulais
2000-05-02  0:00   ` JP Thornley
2000-05-11  0:00     ` jboulais
2000-05-13  0:00       ` JP Thornley

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