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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c83229a21d53b2b3 X-Google-Attributes: gid103376,public From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) Subject: Re: Long Float Error from Gnat Date: 1998/10/30 Message-ID: #1/1 X-Deja-AN: 406906965 References: <3638F49C.E90A401E@easystreet.com> Organization: * JerryWare *, Leiden, Holland Newsgroups: comp.lang.ada Date: 1998-10-30T00:00:00+00:00 List-Id: Al Christians (achrist@easystreet.com) wrote: : I've hit an odd numerical error in a program that I've compiled : with GNAT 3.10p1 on NT 4 sp3. I almost can't believe it, so I wonder : if anyone else can tell me what's going on. My number one suspect is : that it's a floating point problem in my Pentium Pro. I'm no expert on this, but there seems to be something strange here. I would have expected both procedures below to give identical results: with Ada.Text_IO; with Ada.Long_Float_Text_IO; procedure My_Test is package Long_Float_IO is new Ada.Text_IO.Float_IO (Long_Float); procedure Check_Gnat (N : in Long_Float; S : in String) is Result : Long_Float; Last : Positive; begin Ada.Text_IO.Put_Line (N'Img); Ada.Long_Float_Text_IO.Put (N); Ada.Text_IO.New_Line; Ada.Long_Float_Text_IO.Get (S, Result, Last); Ada.Text_IO.Put_Line ("Last is" & Last'Img); if Result = N then Ada.Text_IO.Put_Line ("String equals number"); else Ada.Text_IO.Put_Line ("String does not equal number"); end if; Ada.Text_IO.Put_Line (Result'Img); Ada.Long_Float_Text_IO.Put (Result); Ada.Text_IO.New_Line; Ada.Text_IO.New_Line; end Check_Gnat; procedure Check_My (N : in Long_Float; S : in String) is Result : Long_Float; Last : Positive; begin Ada.Text_IO.Put_Line (N'Img); Long_Float_IO.Put (N); Ada.Text_IO.New_Line; Long_Float_IO.Get (S, Result, Last); Ada.Text_IO.Put_Line ("Last is" & Last'Img); if Result = N then Ada.Text_IO.Put_Line ("String equals number"); else Ada.Text_IO.Put_Line ("String does not equal number"); end if; Ada.Text_IO.Put_Line (Result'Img); Long_Float_IO.Put (Result); Ada.Text_IO.New_Line; Ada.Text_IO.New_Line; end Check_My; begin Ada.Text_IO.Put_Line ("GNAT:"); Check_Gnat (1.000000000E-32, "1.000000000E-32"); Ada.Text_IO.Put_Line ("Mine:"); Check_My (1.000000000E-32, "1.000000000E-32"); end My_Test; -- -- Jerry van Dijk | email: jdijk@acm.org -- Leiden, Holland | member Team-Ada -- Ada & Win32: http://stad.dsl.nl/~jvandyk