Path: csiph.com!aioe.org!.POSTED!not-for-mail From: "AK" Newsgroups: pl.comp.lang.python Subject: Re: Martwa grupa? Date: Sat, 17 Feb 2018 21:38:13 +0100 Organization: Aioe.org NNTP Server Lines: 41 Message-ID: References: <5a7d67d3$0$566$65785112@news.neostrada.pl> <5ce2d437-0c82-4cc2-8ca4-a2eb188237b7@googlegroups.com> <5a7d7652$0$665$65785112@news.neostrada.pl> <1w9lbxu5j97oe.dlg@tyczka.com> <5a7d8ff9$0$675$65785112@news.neostrada.pl> <1bjuq22x745gf$.dlg@tyczka.com> <5a7d9749$0$668$65785112@news.neostrada.pl> <506f1997-6b94-4c64-9e25-2c022f5aac62@googlegroups.com> NNTP-Posting-Host: jHM0fgmX8PLRSmVRRAzYag.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=response Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.19694 X-Antivirus: Avast (VPS 180217-2, 2018-02-17), Outbound message X-Antivirus-Status: Clean X-MSMail-Priority: Normal X-Notice: Filtered by postfilter v. 0.8.3 X-Newsreader: Microsoft Windows Mail 6.0.6002.18197 Xref: csiph.com pl.comp.lang.python:108 Użytkownik "slawek" napisał: > Nie każdy liczy tylko liczbę sznurówek i rolek papieru toaletowego. No widzisz? Nawet Twoj ulubiony Lahey (i to w lata temu: 1996) uczy jak trzeba postepowac w Fortranie (i w ogole) z FP (i to w wersji roznicy wzglednej - czyli najbardziej odpowiedniej): http://www.lahey.com/float.htm a tam: Safe Comparisons ------------------- Different computers use different numbers of bits to store floating-point numbers. Even when the same IEEE formats are used for storing numbers, differences in calculations can occur because of the size of intermediate registers. To increase portability and to ensure consistent results, I recommend against comparing for exact equality of real numbers in FORTRAN. A better technique is to compare the absolute value of the difference of two numbers with an appropriate epsilon to get relations like approximately equal, definitely greater than, etc. Example: REAL EPSILON, X, A, B PARAMETER (EPSILON = .000001) DATA A/13.9/, B/.000005/ X = (A * B) / B IF (ABS(X - A) .LE. (ABS(X)*EPSILON)) THEN PRINT *, 'X is approximately equal to A' ENDIF IF ((X - A) .GT. (ABS(X)*EPSILON)) THEN PRINT *, 'X is definitely greater than A' ENDIF IF ((A - X) .GT. (ABS(X)*EPSILON)) THEN PRINT *, 'X is definitely less than A' ENDIF END Jak widac pokrywa sie w pelni z tym co uprzednio napisalem. AK