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 14:30:45 -0700 Organization: None to speak of Lines: 31 Message-ID: <8734174vzu.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> <87bjfw4jq5.fsf@example.invalid> <10r147c$2c38c$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 06 Apr 2026 21:30:48 +0000 (UTC) Injection-Info: dont-email.me; posting-host="c89d67d6d7dc44c8a8f559dd5aa96ee5"; logging-data="2523272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FUAwwTQT1UTKhtr1dcK/B" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Ho0NzmWr/sSUJi/wpUuVQHAsSKI= sha1:nEoEdbfHGUZy/Dve1FSwjolHxWk= Xref: csiph.com rec.arts.sf.written:655857 rec.arts.comics.strips:67125 comp.lang.fortran:126593 comp.lang.c++:123682 Thomas Koenig writes: > Keith Thompson schrieb: >> Thomas Koenig writes: [...] >>> 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 > > Not quite the same. SELECTED_REAL_KIND gives you the > _minimum_ real type for your requirements. You can do that in C or C++ too, though not as cleanly. With a series of #if directives, you can select the minimal floating-point type (out of float, double, long double) that satisfies some requirement. But I don't recall ever seeing code that does this. This is rapidly going off-topic for most of the newsgroups this is posted to, so I won't go into more detail. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */