Article View: comp.lang.c
Article #924Re: .5 against 0.5f
From: fir
Date: Wed, 28 Oct 2026 06:32
Date: Wed, 28 Oct 2026 06:32
52 lines
2847 bytes
2847 bytes
Steven G. Kargl pisze:
> On Wed, 28 Oct 2026 00:49:19 -0000 (UTC), Lawrence D’Oliveiro wrote:
>
>> On Tue, 27 Oct 2026 18:06:25 -0400, James Kuyper wrote:
>>
>>> However, if you need double precision, you shouldn't be using the
>>> "f" suffix.
>>
>> Is there any situation where you *should* use the “f” suffix?
>>
>> I am thinking: no.
>
> % cat j8.c
> float
> foo(int n, float *x)
> {
> float s = 0;
> for (int i = 0; i < n; ++i) {
> s += x[i] * 0.1;
> }
> return (s);
> }
>
> % cc -o z.s -O3 -S j8.c && grep cvts z.s
> cvtss2sd %xmm2, %xmm2
> cvtss2sd %xmm0, %xmm0
> cvtsd2ss %xmm2, %xmm0
> cvtss2sd %xmm3, %xmm2
> cvtss2sd %xmm0, %xmm0
> cvtsd2ss %xmm2, %xmm0
> cvtss2sd %xmm0, %xmm1
> cvtss2sd %xmm0, %xmm0
> cvtsd2ss %xmm0, %xmm0
>
> That's a lot of useless conversion if 0.1f would have been
> good enough. Change 0.1 to 0.1f in the above code.
>
> % cc -o z.s -O3 -S j8.c && grep cvts z.s | wc -l
> 0
>
> HTH
>
if so its totally terrible, i was kinda not aware of that
i would say its wrong and stupid probably becouse in float computations
such numbers should be floats imo in doubles it should be doubles
i should run my own test but im too exhausted
Technical Details
Message-ID:
<11bs4tj$26daj$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-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> <11brkco$21oj5$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: fir <profesor.fir@gmail.com> Newsgroups: comp.lang.c Subject: Re: .5 against 0.5f Date: Wed, 28 Oct 2026 07:32:14 +0100 Organization: A noiseless patient Spider Lines: 52 Message-ID: <11bs4tj$26daj$1@dont-email.me> 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> <11brkco$21oj5$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 28 Oct 2026 06:32:19 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2307411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+n2+LRXyn1sIFwwERE30ixjadAIysLMNo="; posting-host="0c05802531f1a4b723135877d29c6d22" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0 SeaMonkey/2.53.24 Cancel-Lock: sha1:DesVcBxnU78jCil+z+9FJ//X1jQ= sha256:O8FhDH94C7Koh7n8bKm+lGualzOrBLn4vqNdeZYl9bM= sha1:oEtML8+f5hiLqUl7I4n4CYjAldk= sha256:iC2fMGaYmQpYa4gaC20NjQuA0ACc4pGN31ToLSzMYnE= In-Reply-To: <11brkco$21oj5$1@dont-email.me>