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.9 required=5.0 tests=BAYES_00 autolearn=ham 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-11 13:13:30 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!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Gnat/Windows float point Q Date: 11 Apr 2003 20:11:47 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1050092009 1687 62.49.19.209 (11 Apr 2003 20:13:29 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 11 Apr 2003 20:13:29 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:36097 Date: 2003-04-11T20:11:47+01:00 List-Id: tmoran@acm.org writes: > > I'd expect the result of such an operation to be either +infinity > > or -infinity. Those compare as you expect, and probably raise > > Constraint_Error when stored (if they didn't do that, the compiler would > > be violating the rule about math always returning the correct result or > > raising an exception). > > 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? > > with ada.numerics.complex_types, > ada.text_io; > procedure oflow is > use ada.numerics.complex_types; > x : complex := (4.7E+17, -1.6E+17); > y : float; > begin > for i in 1 .. 5 loop > y := abs(x); > ada.text_io.put_line("abs(x) = y =" & float'image(y) > & " y < 0.0 " & boolean'image(y < 0.0) > & " y >= 0.0 " & boolean'image(y >= 0.0)); > ada.text_io.put_line(float'image(re(x)) & float'image(im(x))); > ada.text_io.put_line(float'image(re(x)) & ":" & float'image(im(x))); > ada.text_io.new_line; > x := x**2; > end loop; > end oflow; > > 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 > > abs(x) = y =1.95300E+05 y < 0.0 FALSE y >= 0.0 FALSE > +Inf*******1.50400E+05 > +Inf*******:1.50401E+05 > > abs(x) = y =+Inf******* y < 0.0 FALSE y >= 0.0 FALSE > 3.36210E-49321.50401E+05 > 9.52681E+139:1.50402E+05 > > abs(x) = y =9.52681E+05 y < 0.0 FALSE y >= 0.0 FALSE > 0.E+051.50402E+05 > 3.64520E-4951:1.50403E+05 With GNAT 3.16a (compiled here for Mandrake 8.2), -gnato -O2, this gives 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 abs(x) = y =NaN******** y < 0.0 FALSE y >= 0.0 FALSE +Inf*******NaN******** +Inf*******:NaN******** abs(x) = y =NaN******** y < 0.0 FALSE y >= 0.0 FALSE NaN********NaN******** NaN********:NaN******** abs(x) = y =NaN******** y < 0.0 FALSE y >= 0.0 FALSE NaN********NaN******** NaN********:NaN******** (at least with NaN it's correct that the comparisons are false both ways). With gcc-3.3-20030201 the result is 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 abs(x) = y =0.E+05 y < 0.0 FALSE y >= 0.0 FALSE +Inf*******0.E+05 Execution terminated by unhandled exception Exception name: CONSTRAINT_ERROR Message: s-imgrea.adb:235 explicit raise Call stack traceback locations: 0x804a581 0x805813d 0x80587bc 0x8057d6f 0x804a29d 0x8049e47 (traceback: shows oflow.adb:14)