🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #944

Re: .5 against 0.5f

#944
From: Tim Rentsch
Date: Wed, 28 Oct 2026 13:54
45 lines
3300 bytes
James Kuyper <jameskuyper@alumni.caltech.edu> writes:

> On 2026-10-27 15:54, Steven G. Kargl wrote:
>> On Tue, 27 Oct 2026 20:15:20 +0100, fir wrote:
>>> Steven G. Kargl pisze:
>>>> On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:
>>>>> Steven G. Kargl pisze:
>>>>>> On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:
>>
>> (snip)
>>
>>>>> but the question is:  can using .1 instead of 0.1f make me any
>>>>> harm in code?  like things get slower in runtime?  (assuming i
>>>>> use floats in code not doubles, and the code is a bit time
>>>>> critical like rasterisation goes on floats) why the ai so
>>>>> maniacally puts that f?
>>>>
>>>> Without seeing code and not knowing whether you are concerned
>>>> with the propagation of floating point errors, the only answer
>>>> that one can give for your first two questions is "yes, no,
>>>> maybe".
>>>>
>>>> AI is likely appending the f because you instructed AI to use a
>>>> float type.  Why not ask AI why it appends the f?
>>>
>>> it says:  i add f that the number would be float type instead of
>>> double
>>>
>>> float x=a*1.5;
>>>
>>> it also says in such above case the multiplication would be in
>>> double then converted to float - bout for me its hard to belive
>
> The standard requires that "The usual arithmetic conversions are
> performed on the operands."  (6.5.6p4).  Those conversions are
> described in (6.3.2.8), and require that, in a*1.5, the value of a
> must be converted to a double, and that the multiplication be
> carried out using double arithmetic.  However, no conversion is
> required for a*1.5f, and the multiplication is carried out using
> float arithmetic.  [...]

Maybe.  IIANM the C standard allows floating operations to be
carried out in greater precision than the nominal type of the
expression, and thus a*1.5f might very well be carried out using,
e.g., the same operations as would be used by double.
Technical Details
Message-ID: <86tsm6lym3.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> <11bqo8h$1o2l4$2@dont-email.me> <11bqsef$1pnhi$1@dont-email.me> <11bqt88$1q9r2$1@dont-email.me> <11bqvh3$1qqsr$1@dont-email.me> <11br6ug$1u3vq$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!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Wed, 28 Oct 2026 06:54:12 -0700
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <86tsm6lym3.fsf@linuxsc.com>
References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11bqo8h$1o2l4$2@dont-email.me> <11bqsef$1pnhi$1@dont-email.me> <11bqt88$1q9r2$1@dont-email.me> <11bqvh3$1qqsr$1@dont-email.me> <11br6ug$1u3vq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 28 Oct 2026 13:54:13 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2599665"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX180ZowXkiP07pPSgAWMnPil1ycIksZtGwI="; posting-host="863330b5bd13e85d720b0575444f578b"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:CfoUpQvfJkD5gxrJoPYvvm1t/MA=
	sha1:l3+mUEbIYOlo53TJwMMR7VlufLU= sha256:6ovvDcXhu1zBb77gXbLKJTPxXDpgKMzeeVDthIvTWH8=
	sha1:IllYyi0ZhOElBvmX2t9T8G3ydKs= sha256:c0q5tA89Nj6modGwtP3m2QeXVyRf8PcdHJqg/AJ9mKg=