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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,64012d256cd76a8d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-10 17:54:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!freenix!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Gnat/Windows float point Q Date: Thu, 10 Apr 2003 19:52:10 -0500 Organization: ENST, France Message-ID: References: Reply-To: "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1050022476 5185 137.194.161.2 (11 Apr 2003 00:54:36 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 11 Apr 2003 00:54:36 +0000 (UTC) To: "comp.lang.ada mail to news gateway" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:36071 Date: 2003-04-10T19:52:10-05:00 Could this paragraph from the GNAT Reference Manual have any bearing on this problem? 9.31 GNAT.Float_Control (`g-flocon.ads') Provides an interface for resetting the floating-point processor into the mode required for correct semantic operation in Ada. Some third party library calls may cause this mode to be modified, and the Reset procedure in this package can be used to reestablish the required mode. ----- Original Message ----- From: Newsgroups: comp.lang.ada To: Sent: April 10, 2003 4:58 PM Subject: Re: Gnat/Windows float point Q > >> Is this a legitimate output, in terms of exceptions (none), comparisons > >>(the last three are False in both directions) and float'image (missing > >>leading blanks and worse), from this program? > > > >Hard to say; I don't understand the rules of Complex math that well. But > >I do find the results of the comparisons to be pretty weird. Have you > >tried this on a different compiler? > Neither of my other compilers has Ada.Numerics.Complex_Types. However, > the complex arithmetic in this program is trivial, so I dropped that > and made q&d Float functions. Gnat still screws up as before, so it's > a Float, not a Complex, problem. The other two compilers raise > exceptions instead of generating garbage. > > 1 with Ada.Exceptions, > 2 ada.numerics.elementary_functions, > 3 ada.text_io; > 4 procedure oflow2 is > 5 use ada.numerics.elementary_functions; > 6 type complex is record > 7 re, im : float; > 8 end record; > 9 function "**"(left:complex; right:positive) return complex is > 10 result : complex := left; > 11 begin > 12 for i in 2 .. right loop > 13 result := (re => left.re * result.re - left.im * result.im, > 14 im => left.re * result.im + left.im * result.re); > 15 end loop; > 16 return result; > 17 end "**"; > 18 function "abs"(x : complex) return float is > 19 begin > 20 return ada.numerics.elementary_functions.sqrt(x.re**2 + x.im**2); > 21 end "abs"; > 22 function re(x:complex) return float is > 23 begin return x.re;end re; > 24 function im(x:complex) return float is > 25 begin return x.im;end im; > 26 x : complex := (4.7E+17, -1.6E+17); > 27 y : float; > 28 begin > 29 for i in 1 .. 5 loop > 30 y := abs(x); > 31 ada.text_io.put_line("abs(x) = y =" & float'image(y) > 32 & " y < 0.0 " & boolean'image(y < 0.0) > 33 & " y >= 0.0 " & boolean'image(y >= 0.0)); > 34 ada.text_io.put_line(float'image(re(x)) & float'image(im(x))); > 35 ada.text_io.put_line(float'image(re(x)) & ":" & float'image(im(x))); > 36 ada.text_io.new_line; > 37 x := x**2; > 38 end loop; > 39 exception > 40 when oops:others=> > 41 ada.text_io.put_line(ada.exceptions.exception_information(oops)); > 42 end oflow2; > ----------------------- > ObjectAda > abs(x) = y = 4.96488E+17 y < 0.0 FALSE y >= 0.0 TRUE > 4.70000E+17-1.60000E+17 > 4.70000E+17:-1.60000E+17 > > CONSTRAINT_ERROR (numeric overflow) > Exception traceback: > 20 oflow2.abs oflow2.adb > 30 oflow2 oflow2.adb > Exception handled at: > 40 oflow2 oflow2.adb > ----------------------- > Janus > abs(x) = y = 4.96488E+17 y < 0.0 FALSE y >= 0.0 TRUE > 4.70000E+17-1.60000E+17 > 4.70000E+17:-1.60000E+17 > > abs(x) = y = 2.46500E+35 y < 0.0 FALSE y >= 0.0 TRUE > 1.95300E+35-1.50400E+35 > 1.95300E+35:-1.50400E+35 > > CONSTRAINT_ERROR > Floating Point Overflow Detected > On Line Number 14 In OFLOW2.** > Called from line number 37 In OFLOW2 > ----------------------- > Gnat > abs(x) = y = 4.96488E+17 y < 0.0 FALSE y >= 0.0 TRUE > 4.70000E+17-1.60000E+17 > 4.70000E+17:-1.60000E+17 > > abs(x) = y = +Inf******* y < 0.0 FALSE y >= 0.0 TRUE > 1.95300E+35-1.50400E+35 > 1.95300E+35:-1.50400E+35 > > abs(x) = y = +Inf******* y < 0.0 FALSE y >= 0.0 TRUE > +Inf*******-Inf******* > +Inf*******:-Inf******* > > abs(x) = y =0.E+05 y < 0.0 FALSE y >= 0.0 FALSE > 1.19442E-4946-Inf******* > 0.E+05:-Inf******* > > abs(x) = y =0.E+05 y < 0.0 FALSE y >= 0.0 FALSE > 4.84066E-4942Inf******* > 0.E+05:0.E+05 > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada > >