Sujet : Re: xkcd: Day Counter
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : rec.arts.sf.written rec.arts.comics.strips comp.lang.fortran comp.lang.c++Date : 06. Apr 2026, 21:14:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <10r147c$2c38c$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : slrn/1.0.3 (Linux)
Keith Thompson <Keith.S.Thompson+
u@gmail.com> schrieb:
Thomas Koenig <tkoenig@netcologne.de> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> schrieb:
Chris Ahlstrom <OFeem1987@teleworm.us> writes:
Lynn McGuire wrote this screed in ALL-CAPS:
xkcd: Day Counter
https://xkcd.com/3228/
>
Yes, floating point errors are the bane of my life ! Not so much now
with double precision but the single precision days were nightmares.
>
Well these days we have long double.
>
C has had long double as a standard type since the original 1989
ANSI C standard. (K&R1, 1978, didn't have long double.)
>
But wider floating-point types don't eliminate rounding errors.
>
Nor does "long double" have to be any more accurate thean
"double". C's type system leaves something to be desired
in that respect.
>
Fortran showed how it's done with its kind numbers and
SELECTED_REAL_KIND function - you ask for a certain minimum
precision, and the compiler either gives it to you, or your program
fails at compile time.
>
You can do the same thing in C or C++ with a compile-time test.
>
#include <float.h>
>
#if LDBL_DIG < 18
#error "long double doesn't have enough precision"
#endif
Not quite the same. SELECTED_REAL_KIND gives you the
_minimum_ real type for your requirements.
-- This USENET posting was made without artificial intelligence,artificial impertinence, artificial arrogance, artificial stupidity,artificial flavorings or artificial colorants.
Haut de la page
Les messages affichés proviennent d'usenet.
NewsPortal