Article View: comp.lang.c
Article #1111Re: .5 against 0.5f
From: Keith Thompson
Date: Thu, 29 Oct 2026 11:54
Date: Thu, 29 Oct 2026 11:54
35 lines
2998 bytes
2998 bytes
David Brown <david.brown@hesbynett.no> writes:
> On 29/10/2026 00:08, Janis Papanagnou wrote:
>> On 2026-10-28 21:27, Keith Thompson wrote:
>>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> [...]
>
>>> But 0.1f
>>> and 0.1 are of different types. If they happen to behave the same way
>>> in some context, it's a consequence of the C language rules.
>> Yes, sure. Only that I think that context should suffice to
>> interpret
>> "0.1" appropriately!
>
> Do you mean that you think it would have been better if the rules of C
> were different, so that the context always determined how "0.1" was to
> be interpreted? That's not an unreasonable feature for a programming
> language - AFAIUI, that is how numeric literals work in Ada. But it
> is not how things work in C, where the value and type of an expression
> is determined entirely by the expression itself, independently of the
> context.
Strictly speaking, the type of a numeric literal in Ada is
<universal_integer> or <universal_real>. Both types are anonymous,
have effectively infinite precision, and exist only at compile time.
There's an implicit conversion to the type determined by the context
(one of the few implicit conversions in Ada).
The effect is similar to what you'd get if the type of a literal
depending on its context.
[...]
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID:
<11bvc5c$3a06t$1@kst.eternal-september.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> <11brir0$1uh9q$4@kst.eternal-september.org> <11bt4ua$139ta$8@dont-email.me> <11btlrl$2ojn1$1@kst.eternal-september.org> <11btv9c$139ta$12@dont-email.me> <11bv06a$34ll3$2@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: .5 against 0.5f Date: Thu, 29 Oct 2026 04:54:20 -0700 Organization: None to speak of Lines: 35 Message-ID: <11bvc5c$3a06t$1@kst.eternal-september.org> References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> <11brir0$1uh9q$4@kst.eternal-september.org> <11bt4ua$139ta$8@dont-email.me> <11btlrl$2ojn1$1@kst.eternal-september.org> <11btv9c$139ta$12@dont-email.me> <11bv06a$34ll3$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 29 Oct 2026 11:54:21 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="3473629"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bb6U18DEvc1bY9JnpQlMz"; posting-host="6d0778e7cc40265319e665d37d9f3d3e" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:vZ5FvoT52Op/GAXjmTnSX/2lXGc= sha256:4M0Z6TaZiXIK60HtGIWQVGVv4uMU/M1CPaP+VsJcsnw= sha1:B5cLavoAJOob6OfQZaFilx9rlyw= sha256:6jW0pzgJ3GCB/9y+tB8EXfJNpmsnoHcA0Tn11BvcB+E=