Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: rec.arts.sf.written,rec.arts.comics.strips,comp.lang.fortran,comp.lang.c++ Subject: Re: xkcd: Day Counter Date: Mon, 06 Apr 2026 00:43:30 -0700 Organization: None to speak of Lines: 37 Message-ID: <87bjfw4jq5.fsf@example.invalid> References: <10qq170$d49s$2@dont-email.me> <10qtr82$1f4di$2@dont-email.me> <87mrzhp0tt.fsf@example.invalid> <10qvg49$1t2f3$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 06 Apr 2026 07:43:32 +0000 (UTC) Injection-Info: dont-email.me; posting-host="c89d67d6d7dc44c8a8f559dd5aa96ee5"; logging-data="2055030"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HReQPAVwR9AseNUW1J5MG" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:iZ6X0SsR4zGKo60iH3fGohCrw2Q= sha1:xV8HPWIcyJpf1RYRozNCmrqtmS4= Xref: csiph.com rec.arts.sf.written:655827 rec.arts.comics.strips:67119 comp.lang.fortran:126586 comp.lang.c++:123670 Thomas Koenig writes: > Keith Thompson schrieb: >> Chris Ahlstrom 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 #if LDBL_DIG < 18 #error "long double doesn't have enough precision" #endif -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */