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,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no 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 05:37:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!deine.net!teaser.fr!enst!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: I think - it's a bug... Date: Mon, 11 Mar 2002 07:43:03 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <3C8B184D.49214059@yahoo.com> <3C8C41A8.B5D96800@yahoo.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1015853822 88050 137.194.161.2 (11 Mar 2002 13:37:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 11 Mar 2002 13:37:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: rhezusfactor@yahoo.com Xref: archiver1.google.com comp.lang.ada:21046 Date: 2002-03-11T07:43:03-06:00 I think what happens when the put_line call is present is that the C runtime library is called, which on NT can result in the FPU unit state being changed, hence the desirability (or need) to call GNAT.Float_Control.Reset, as suggested. The statement from the UG _was_ included, and is: In particular, if the Ada code will do any floating-point operations, then the FPU must be setup in an appropriate manner. For the case of the x86, for example, full precision mode is required. The procedure GNAT.Float_Control.Reset may be used to ensure that the FPU is in the right state. ----- Original Message ----- From: "Anatoly Chernyshev" Newsgroups: comp.lang.ada To: Sent: Sunday, March 10, 2002 11:33 PM Subject: Re: I think - it's a bug... > > > "David C. Hoos, Sr." wrote: > > > This is not a bug. The problem comes about by not being aware of > > the nature of floating point representation in computers. > > > > In your example, the value of dz (0.3) is not exactly representable in > > binary -- it is an infinitely repeating binary fraction. Hence, all values of > > z that you compute are not exactly representable. > > > > Thus, if the value of dz was rounded upward to the next lsb when > > converting from decimal to binary, all values of z will be slightly > > larger than their true value. > > > > That's true, but still, why inserting of "put_line (float'image(1.0-(z/b)));" > influences the behaviour of the program so much. > Beyound that, I've got similar things with z=0.1 and 0.25. They were solved > though, by using different optomization levels (-O, -O2...). > > > > > > The only solution is to test the values of which you are about to take > > the square root, and if the absolute value is less than some very small > > threshold, set the value to 0.0. > > > > Alternatively, if you are sure (given the nature of the problem you > > are solving) that z can never be greater than b, you could replace > > (z/b) by Float'Min (1.0, z/b). > > > > Additionally, you might want to consider the following statement > > from the GNAT User's Guide: > > In particular, if the Ada code will do any floating-point operations, > > then the FPU must be setup in an appropriate manner. For the case > > of the x86, for example, full precision mode is required. The > > procedure GNAT.Float_Control.Reset may be used to ensure that > > the FPU is in the right state. > > > Finally you can obtain greater precision by using Long_Float or Long_Long_Float > > instead of Float. > > Thanks a lot for those suggestions (but you are omitted what is coming from the > GNAT UG). > > > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >