Article View: comp.lang.c
Article #1112Re: .5 against 0.5f
From: Keith Thompson
Date: Thu, 29 Oct 2026 11:59
Date: Thu, 29 Oct 2026 11:59
19 lines
2235 bytes
2235 bytes
David Brown <david.brown@hesbynett.no> writes:
> On 28/10/2026 21:25, Michael S wrote:
[...]
>> I'd still likely prefer to write it as (float)0.1 instead of 0.1f.
>> It somewhat depends on my mood in specific day, but likelihood is
>> certainly not in favor of 0.1f.
>>
> That seems a bit excessive to me, but okay. The principle is the
> same, making it clear to the reader and the compiler that no
> double-precision arithmetic is involved.
Except that, at least in the abstract machine, `(float)0.1` produces
a value of type double and converts it to float. It's likely that
a compiler would generate the same code as for `0.1f`, but I'd want
to confirm that if it mattered. (Actually, I'd just write `0.1f`.)
--
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:
<11bvcea$3a06t$2@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> <11bs8rb$26dq0$1@dont-email.me> <20261028222504.00004b8b@yahoo.com> <11bv4q0$37eth$1@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:59:06 -0700 Organization: None to speak of Lines: 19 Message-ID: <11bvcea$3a06t$2@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> <11bs8rb$26dq0$1@dont-email.me> <20261028222504.00004b8b@yahoo.com> <11bv4q0$37eth$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 29 Oct 2026 11:59:07 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="3473629"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4JLPqQNRjzA7c9aiVHKNf"; posting-host="6d0778e7cc40265319e665d37d9f3d3e" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:xHgW+Dlrkj+kHM3eiQtLk3dXc/Y= sha256:vejQ6Fz8zeyauVPYT4yLqFyxdvOuYITXxH94/0upUS0= sha1:lXKvgxQo19lQmGyY5nICx68Iboc= sha256:pBeSRzTtca9HGqaOVqWIyMaryTXjDXoiCHixRhiRzVk=