🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #883

Re: .5 against 0.5f

#883
From: David Brown
Date: Tue, 27 Oct 2026 20:35
46 lines
3224 bytes
On 27/10/2026 20: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
>>
> 
> I do not know where to begin to address the above.  Perhaps,
> find a copy of K&R to read.
> 

For your benefit (not for Fir's), the multiplication of "a * 1.5" would 
be done in double precision (unless "a" is a "long double").  The 
resulting double value would then be converted to a single-precision float.

Whether "a * 1.5f" is done as single (float) or double depends on the 
type of "a" - if it is a "double", then the float value 1.5f gets 
converted to a double (and may be slightly different from 1.5) and the 
multiplication is done as double precision.  If "a" is of type "float", 
then the multiplication is done as single precision.

Technical Details
Message-ID: <11br1v4$1s1rj$1@dont-email.me>
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>

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: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Tue, 27 Oct 2026 21:35:48 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <11br1v4$1s1rj$1@dont-email.me>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 27 Oct 2026 20:35:49 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1967987"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18J7dW6abmv9jj2bVZmdumF1TxBTqm9lnQ="; posting-host="e6aab6e4881312e149db0ba3ba45b112"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:F1vTLJks+JfGL38w/IdVjZPVkTc= sha256:qNoPX7QLNChJdyiFnOPtGHoBjAjZAFbHV8vOsQ/yRtg=
	sha1:zCaTHinyaCJp33hCCKc5j6/ZbQI= sha256:aPUd2GfmSNO/v6tVizKvk/otrbPTk0oul3+Hj3kTQro=
Content-Language: en-GB
In-Reply-To: <11bqvh3$1qqsr$1@dont-email.me>