Article View: comp.lang.c
Article #886Re: .5 against 0.5f
From: Michael S
Date: Tue, 27 Oct 2026 20:51
Date: Tue, 27 Oct 2026 20:51
80 lines
3682 bytes
3682 bytes
On Tue, 27 Oct 2026 22:05:06 +0200
Michael S <already5chosen@yahoo.com> wrote:
> On Tue, 27 Oct 2026 21:43:42 +0200
> Michael S <already5chosen@yahoo.com> wrote:
>
> > On Tue, 27 Oct 2026 18:40:52 GMT
> > scott@slp53.sl.home (Scott Lurndal) wrote:
> >
> > > "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu>
> > > writes:
> > > >On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:
> > > >
> > > >> if ai generates me some functions it puts everywhere this f at
> > > >> the and yet it add zeros so instead of .1 i got 0.1f
> > > >>
> > > >> and i obviously dont like it
> > > >>
> > > >> i write hvever some codes when i need speed so the question is
> > > >> may it give some difference?
> > > >>
> > > >> i mean .1 maybe can be treated as doube constants so mabe
> > > >> occupies some more memory (?) or uses some casting in
> > > >> coplutations (?)
> > > >>
> > > >>
> > > >> i doubt it probably it makes difference but im strictly not
> > > >> sure
> > > >
> > > >The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
> > > >code easier to read. The difference between 0.1 and 0.1f with
> > > >their binary representations is a another matter.
> > > >
> > > >#include <stdio.h>
> > > >
> > > >int
> > > >main(void)
> > > >{
> > > > double d;
> > > > d = 0.1f;
> > > > printf("%.13a\n", d);
> > > > d = 0.1;
> > > > printf("%.13a\n", d);
> > > > return (0);
> > > >}
> > > >
> > > >% cc -o z t.c && ./z
> > > >0x1.99999a0000000p-4
> > > >0x1.999999999999ap-4
> > > >
> > > >The real number is 0.1 is not exactly representable in a binary
> > > >floating point format. See
> > > >
> > > >https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
> > > >
> > >
> > > I ordered a couple of blu-rays from amazon last week, and the
> > > confirmation email had the following for the total price:
> > >
> > > Total
> > > 75.71000000000001 USD
> > >
> > > Appears they may be using FP instead of integer fixed point
> > > arithmetic for pricing.
> >
> > At least, unlike favorite AI of fir, Amazon was not using
> > single-precision.
> >
> >
> >
>
> BTW, 75.71000000000001 looks like 67 * 1.13 in IEEE binary64, but
> rounded up rather than to nearest.
>
Or 67 + 67 * 0.13 rounded to nearest.
Technical Details
Message-ID:
<20261027225141.000076e0@yahoo.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-mailReferences:
<11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <Ue6ES.2265$y_V1.1859@fx12.iad> <20261027214342.000022c4@yahoo.com> <20261027220506.0000321d@yahoo.com>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: Michael S <already5chosen@yahoo.com> Newsgroups: comp.lang.c Subject: Re: .5 against 0.5f Date: Tue, 27 Oct 2026 22:51:41 +0200 Organization: A noiseless patient Spider Lines: 80 Message-ID: <20261027225141.000076e0@yahoo.com> References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <Ue6ES.2265$y_V1.1859@fx12.iad> <20261027214342.000022c4@yahoo.com> <20261027220506.0000321d@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Tue, 27 Oct 2026 20:51:44 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1982399"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ls0KK0cp7mGeB2EqHirsk5ktB4ANIrew="; posting-host="8efa9109d06590231713727ed89af78c" Cancel-Lock: sha1:cxREdikFWkQLI8/3EfLU486Cq18= sha256:0GIpBaUmaqb+pZGRPj+yApqcZIGvx733Oxo8tkkOoO8= sha1:U/5HIpXNp0S2UlNdGBUzbaMZq2s= sha256:c3pWfiMFevdRCr789Sqhjzln0X7p3dOhfk/clJZW5Uw= X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)