🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #28612

Re: Martwa grupa?

#28612
From: AK
Date: Sat, 17 Feb 2018 20:38
40 lines
2891 bytes
Użytkownik "slawek" <fake@fakeemail.com> 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
Technical Details
Message-ID: <p6a3st$cje$1@gioia.aioe.org>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail
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> <almarsoft.4582477572672930050@news.v.pl> <p67qh7$qfc$1@gioia.aioe.org> <almarsoft.8819544339485526967@news.v.pl> <p690ps$ck4$1@gioia.aioe.org> <almarsoft.8137023269573244304@news.v.pl> <p69ig8$1anq$1@gioia.aioe.org> <almarsoft.2189709423721289494@news.v.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail
From: "AK" <nobody@nowhere.net>
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: <p6a3st$cje$1@gioia.aioe.org>
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> <almarsoft.4582477572672930050@news.v.pl> <p67qh7$qfc$1@gioia.aioe.org> <almarsoft.8819544339485526967@news.v.pl> <p690ps$ck4$1@gioia.aioe.org> <almarsoft.8137023269573244304@news.v.pl> <p69ig8$1anq$1@gioia.aioe.org> <almarsoft.2189709423721289494@news.v.pl>
NNTP-Posting-Host: jHM0fgmX8PLRSmVRRAzYag.user.gioia.aioe.org
Mime-Version: 1.0
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
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit