🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1338

Re: .5 against 0.5f

#1338
From: Tim Rentsch
Date: Thu, 05 Nov 2026 14:31
28 lines
2556 bytes
antispam@fricas.org (Waldek Hebisch) writes:

> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
>> 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`.)
>
> Maybe the code will be the same.  But in general going via doubles
> produces less accurate result, [...]

What makes you think using a double will produce a less accurate
result?
Technical Details
Message-ID: <86eccznycg.fsf@linuxsc.com>
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!.POSTED!not-for-mail
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> <11bvcea$3a06t$2@kst.eternal-september.org> <11c4mab$jkma$1@paganini.bofh.team>

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!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Thu, 05 Nov 2026 06:31:59 -0800
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <86eccznycg.fsf@linuxsc.com>
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> <11bvcea$3a06t$2@kst.eternal-september.org> <11c4mab$jkma$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 05 Nov 2026 14:32:02 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1735383"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/GMbOMcxjcYEXgcuu+aLoSlpDKBUM3SCM="; posting-host="1fd0f414c5c4b65accbd3a90ef282996"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:49GQ7p2NpaZqzCHxhbUMF4gZ52M=
	sha1:jMJ2bmNVW8ha7yCZteo9B8U6QjU= sha256:q6gZ0pfOwtpZ8Q8A4Muy34TPZUBHSwPyMZZQuFGHjz4=
	sha1:/GOKdJu/OEePzeNhd+UDyY3IUYg= sha256:TvCDmrFiG9fhv7V7hHi0gaQP98hrtYU3jGFpRF34uO0=