comp.lang.ada
 help / color / mirror / Atom feed
From: Al Christians <achrist@easystreet.com>
Subject: Re: Long Float Error from Gnat
Date: 1998/10/30
Date: 1998-10-30T00:00:00+00:00	[thread overview]
Message-ID: <363A49F3.DB0A0196@easystreet.com> (raw)
In-Reply-To: uaf2ej591.fsf@gsfc.nasa.gov

The problem is a little stranger than previously presented.  The 
program below will generate lots of errors with other values of
aft than 9.  The errors all seem to occur when the negative of the
exponent plus the digits after the decimal equals 41.  Wow!

Al

------------------------------------------------------------------------------

with Ada.Text_Io;
with Ada.Long_Float_Text_Io;
with Ada.Numerics.Long_Elementary_Functions;
with Ada.Numerics.Float_Random;
procedure Numeric_Test is

   The_Generator:  Ada.Numerics.Float_Random.Generator;

   function Generate_Random_Number return Long_Float is
   x:   Long_Float;
   begin
      X := Long_Float( Ada.Numerics.Float_Random.Random( The_Generator )
);
      X := X * 300.0 - 150.0;
      return Ada.Numerics.Long_Elementary_Functions.exp( X );
   end;


   Number_Of_Tests:   Natural := 1_000_000;
   X:       Long_Float;
   Y:       Long_Float;
   Count:   Integer  := 0;
   X_String,
   Y_String:   String(1..30);
   Last_Pos:   Natural;
   Largest:    Long_Float := -99.99E+99;
   Smallest:   Long_Float := +99.99E+99;

begin
   for I in 1..Number_Of_Tests loop
      X := Generate_Random_Number;
         for Digits_Aft in 6..12 loop
            begin
               Ada.Long_Float_Text_Io.Put( X_String, X, Aft =>
Digits_Aft );
               Ada.Long_Float_Text_Io.Get( X_String, Y, Last_Pos );
               Ada.Long_Float_Text_Io.Put( Y_String, Y, Aft =>
Digits_Aft );
               if  X_String /= Y_String then
                  Ada.Text_Io.Put( "Aft =>" & Integer'Image( Digits_Aft
) );
                  Ada.Text_Io.Put( Long_Float'Image(X) );
                  Ada.Text_Io.Put( "   ");
                  Ada.Text_Io.Put( Long_Float'Image(Y) );
                  Ada.Text_Io.New_Line;
                  if  x > Largest then
                     Largest := X;
                  end if;
                  if  x < Smallest then
                     Smallest := X;
                  end if;
                  Count := Count + 1;
               end if;
            exception
               when others =>
                  Ada.Text_Io.Put( "Exception:" & Long_Float'Image(X) );
                  Ada.Text_Io.Put( "   Aft:" & Integer'Image(Digits_Aft)
);
            end;
      end loop;
   end loop;
   Ada.Text_IO.Put_Line( "Largest:  " & Long_Float'Image(Largest) );
   Ada.Text_IO.Put_Line( "Smallest: " & Long_Float'Image(Smallest) );
   Ada.Text_IO.Put_Line( "Count:    " & Integer'Image(Count) );
end Numeric_Test;




  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 ` Jerry van Dijk
1998-10-30  0:00 ` jrcarter001
1998-10-30  0:00   ` Al Christians
1998-10-30  0:00 ` Stephen Leake
1998-10-30  0:00   ` Al Christians [this message]
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
replies disabled

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