From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3f2ed3f93fdb688b X-Google-Attributes: gid103376,public From: jboulais@my-deja.com Subject: Disturbing float conversions... Date: 2000/05/02 Message-ID: <8en7ij$kr7$1@nnrp1.deja.com>#1/1 X-Deja-AN: 618361251 References: <8dfm0q$8nr$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x43.deja.com:80 (Squid/1.1.22) for client 140.76.187.210 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue May 02 18:42:32 2000 GMT X-MyDeja-Info: XMYDJUIDjboulais Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.72 [en] (WinNT; I) Date: 2000-05-02T00:00:00+00:00 List-Id: I'm seeing something similar, but perhaps a little more disturbing (Gnat 3.11p and WinNT 4.0). I've got the following types defined: type Long_Float_Type is digits 8 range -32768.000 .. 32767.000 ; subtype Angle_Type is Long_Float_Type range -180.00000 .. 179.99451 ; I find that when I do a 'Image on the 'First and 'Last of Angle_Type, I get -1.7999872E+02 and 1.7999872E+02 respectively. If I convert to a long_float (Ada standard, not Long_Float_Type) I get -1.80000000000000E+02 and 1.79994510000127E+02 respectively, which is closer, but the 'Last is a little bigger than I defined it to. If I instantiate Text_IO.Float_IO with Angle_Type, I get -204.7 and 204.7, which really blows me away. In article <8dfm0q$8nr$1@nnrp1.deja.com>, David W. Glessner wrote: > 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. > -- ----------------- Jeffrey Boulais Sent via Deja.com http://www.deja.com/ Before you buy.