🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #955

Re: .5 against 0.5f

#955
From: Steven G. Kargl
Date: Wed, 28 Oct 2026 16:22
23 lines
2035 bytes
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.  

-- 
steve
Technical Details
Message-ID: <11bt7ff$2i0ag$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> <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>

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: "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Wed, 28 Oct 2026 16:22:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <11bt7ff$2i0ag$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 28 Oct 2026 16:22:08 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2687312"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/xcS77K3tdtFxaIR5ADYAP"; posting-host="1bf873808c53778ca982afc43c23d859"
User-Agent: Pan/0.164 (Kupiansk)
Cancel-Lock: sha1:SGJgF5tb2elMMIVq3NCLMjswkCE= sha256:9hupMXFSqKpAn9kFE/S14vlAij1BXz9mlJ8sIHgFwdI=
	sha1:T4yegTQCPIuTxcUIa8e01baogvU= sha256:M1Uv6MQ0GSW/gfhgqjWXhf4y8jVdEeBezuQmPuHkHfk=