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: Al Christians Subject: Re: Long Float Error from Gnat Date: 1998/10/30 Message-ID: <363A49F3.DB0A0196@easystreet.com>#1/1 X-Deja-AN: 406831971 Content-Transfer-Encoding: 7bit References: <3638F49C.E90A401E@easystreet.com> Content-Type: text/plain; charset=us-ascii X-Trace: news6.ispnews.com 909789080 206.103.35.35 (Fri, 30 Oct 1998 18:11:20 EDT) Organization: Trillium Resources Corporation MIME-Version: 1.0 NNTP-Posting-Date: Fri, 30 Oct 1998 18:11:20 EDT Newsgroups: comp.lang.ada Date: 1998-10-30T00:00:00+00:00 List-Id: 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;