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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2d09fa6592c24a21 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-11 11:50:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hub1.nntpserver.com!news-xfer2.newshosting.com!not-for-mail Message-ID: <3C8D0A12.5C687100@yahoo.com> Date: Mon, 11 Mar 2002 13:48:34 -0600 From: Anatoly Chernyshev X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: I think - it's a bug... References: <3C8B184D.49214059@yahoo.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: 147.126.101.90 X-Original-Trace: 11 Mar 2002 12:49:59 -0700, 147.126.101.90 X-COMPLAINTS: Report abuse to abuse@mhogaming.com Organization: Newshosting.com - Highest quality at a great price! www.newshosting.com NNTP-Posting-Date: 11 Mar 2002 19:49:56 GMT NNTP-Posting-Host: e8db4873.news.newshosting.com X-Trace: DXC=ZghK_0Oj:b4M`9W3]Vl@g>X`1N4>^k1L3iF6BbIV4YY2LnHEXCOOR@?]UdHH:F16i7M;lF[5C2Pf8o5dZhTdOGR=oh3?Aa9Y?32 X-Complaints-To: abuse@newshosting.com Xref: archiver1.google.com comp.lang.ada:21074 Date: 2002-03-11T19:49:56+00:00 List-Id: Thanks to everyone who tried to answer this post. Eventually, I've found a solution that always put me on the safe side: replace FOR k IN 0..integer(b/dz) LOOP with FOR K IN 0..Integer(Float'Truncation(B/Dz)) LOOP Anatoly Chernyshev wrote: > Look at this piece of code: > > ------------------------------------------------------------------------------------------------- > > WITH ada.text_io,ada.numerics.elementary_functions; > USE ada.text_io, ada.numerics.elementary_functions; > PROCEDURE el_stat_fun IS > b : float := 7.5; > a:float:=4.0; > rr, z : float; > r : float := 4.0; > dz : float := 0.3; > BEGIN > FOR k IN 0..integer(b/dz) LOOP > z:=float(k)*dz; > put_line (float'image(1.0-(z/b))); > rr:=-a*sqrt((1.0-(z/b)**2))+a+r; > END LOOP; > END el_stat_fun; > ---------------------------------------------------------------------------------------------------- > > When compiled using GNAT 3.14 (WinNT sp 6) it raises > ADA.NUMERICS.ARGUMENT_ERROR in sqrt function when k goes to 25 because > the argument for sqrt becomes > negative (like -X.XXXXXE-07 ... And this is a headache No 1). > However, if one comments out the put_line string - everything works > fine. > > I don't know whether this is a bug or feature, but any kind of help for > how to avoid the situation when 1.0-1.0/1.0 yields something different > from 0.0 will be greatly appreciated. > > Thanks in advance, > > Anatoly.