Article View: comp.lang.c
Article #965Re: .5 against 0.5f
From: fir
Date: Wed, 28 Oct 2026 18:47
Date: Wed, 28 Oct 2026 18:47
41 lines
2943 bytes
2943 bytes
fir pisze:
> Steven G. Kargl pisze:
>> On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:
>>
>>> (should i also write 0.0f insetad of 0 BTW?)
>>
>> A lot of context removed. No. IMO, if you have
>> a numerical constant that can be written as an
>> integer and that integer is less than 2^P
>> where P is the precision of the floating point
>> type of interest (here, 2^P means 2 raised to
>> the Pth power), then simply write the numerical
>> constant as an integer. It's easier to read.
>>
>> float foo(float a) {
>> float x = 25 * a;
>> return (x);
>> }
>>
>> A compiler ought to convert 25 in the above to
>> 25.f as 25 is exactly representable (at least in
>> IEEE-754 binary32 format) in float.
>>
> there is something like integer*float multiplication , or not?
> if so 25*a and 25.*a or 25.0f*a could make a difference
and i would say it is good to be able to express what one wants
and write 25*a, 25.0d *a, 25.0f *a //if there would be version for double
but for me its really weird that compiler cant 25.*a resolve as floats
if optimisation is on and put those conversions
same as 25 imo shouldn be treated as int if in runtime faster it would
be if that would be short long or char
imo constant is constant so 25.1 imo even should not represent nor float
nor double but probably the 'ideal' value
Technical Details
Message-ID:
<11btg0s$2mjpd$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> <11bs4tj$26daj$1@dont-email.me> <11bs613$26knh$1@dont-email.me> <11bt7ff$2i0ag$1@dont-email.me> <11bte4h$2lmho$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 19:47:56 +0100 Organization: A noiseless patient Spider Lines: 41 Message-ID: <11btg0s$2mjpd$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> <11bs4tj$26daj$1@dont-email.me> <11bs613$26knh$1@dont-email.me> <11bt7ff$2i0ag$1@dont-email.me> <11bte4h$2lmho$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 18:47:57 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2838317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JClmDlb8hxUTZ1xVNTqs5X1w7qN9ebDw="; 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:9XYdCZe3XLvcRii6FfiARWSyQFQ= sha256:1oZ/POm3Cd9xN8JhwNkD3sxYLiRSOMk4OLsFXW7TKWY= sha1:c5uxDlVF/8PcKPmTIgccP2N2K04= sha256:Is/7K8jAWUrfs+khlonclrpgGVjNp6t2U7VAmgRyHRo= In-Reply-To: <11bte4h$2lmho$1@dont-email.me>