Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: C++ (and some C) quiz questions Date: Wed, 18 May 2022 06:01:05 -0700 Organization: A noiseless patient Spider Lines: 18 Message-ID: <867d6j2dwu.fsf@linuxsc.com> References: <87czgcqxgc.fsf@bsb.me.uk> <86o7zw2x55.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="949c0842145859edcf085e16a5bb4ce2"; logging-data="24768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Gi0TH8EElg9+4kna/ZHOY+Gac0AtjPnI=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:Jt/oV9CMCujDvMRi9WIVbfnu5V8= sha1:k/ezznOmQW75afrImWcDEMGSMco= Xref: csiph.com comp.lang.c++:84166 Juha Nieminen writes: > Tim Rentsch wrote: > >> But that doesn't change the problem of potential loss of >> precision, because the representation (and hence the particular >> value) of the constant 0.1 is chosen before that value is >> converted to long double. The constant 0.1, being of type >> double, doesn't have to have less precision than 0.1L, but >> certainly it can. > > AFAIK no C/C++ compiler will second-guess the programmer and > assume that the literal was meant to be a long double literal. If > you specify a literal of type double, the compiler will assume you > meant it [...] My statement is not about what compilers do but only about what the respective standards allow.