comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Re: Long Float Error from Gnat
Date: 1998/10/30
Date: 1998-10-30T00:00:00+00:00	[thread overview]
Message-ID: <F1Mz7o.HA@jvdsys.nextjk.stuyts.nl> (raw)
In-Reply-To: 3638F49C.E90A401E@easystreet.com

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




      parent reply	other threads:[~1998-10-30  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-29  0:00 Long Float Error from Gnat Al Christians
1998-10-30  0:00 ` Stephen Leake
1998-10-30  0:00   ` Al Christians
1998-10-31  0:00     ` dewar
1998-10-31  0:00       ` Al Christians
1998-11-01  0:00         ` dewarr
1998-11-01  0:00           ` Al Christians
1998-11-01  0:00             ` bob
1998-11-02  0:00               ` Bargin GNAT support prices (Was Re: Long Float Error from Gnat) taashlo
1998-11-03  0:00                 ` dewar
1998-11-02  0:00             ` Long Float Error from Gnat dewar
1998-11-02  0:00               ` dennison
1998-10-30  0:00 ` jrcarter001
1998-10-30  0:00   ` Al Christians
1998-10-30  0:00 ` Jerry van Dijk [this message]
replies disabled

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