Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #83537
| From | Paavo Helde <eesnimi@osa.pri.ee> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Adjusting printf() rounding |
| Date | 2022-04-08 19:38 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <t2podd$ubk$1@dont-email.me> (permalink) |
| References | <t2pag0$eab$1@dont-email.me> <t2pnek$3f5em$1@gwaiyur.mb-net.net> |
08.04.2022 19:21 Marcel Mueller kirjutas:
>> For me this means we have nasty cross-platform differences which we
>> would rather try to avoid. How could we coerce glibc() to round up, or
>> failing that, coerce MSVC to round down?
>
> Why should you care about that difference?
>
> If you have more complex calculations with floating point numbers not
> only the last digit is indeterminate. E.g. transcendental functions
> typically do not provide the maximum possible precision in many FPU
> implementations.
>
> And if you depend on a specific rounding mode you should use your own
> rounding with round/floor/ceil which have well defined behavior.
I'm not concerned about the last (16-th) digit at all. In this case, I'm
concerned about the third digit.
printf("%.3g\n", 212.5) yields 212 in Linux and 213 on Windows.
Even if we could swallow it ourselves, it would be hard to explain our
customers why our software works inconsistently cross platform.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Adjusting printf() rounding Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-08 15:40 +0300
Re: Adjusting printf() rounding Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-04-08 06:02 -0700
Re: Adjusting printf() rounding Marcel Mueller <news.5.maazl@spamgourmet.org> - 2022-04-08 18:21 +0200
Re: Adjusting printf() rounding Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-08 19:38 +0300
Re: Adjusting printf() rounding Sams Lara <samlara622@gmail.com> - 2022-04-08 18:48 +0100
Re: Adjusting printf() rounding Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-08 23:44 +0300
Re: Adjusting printf() rounding Marcel Mueller <news.5.maazl@spamgourmet.org> - 2022-04-09 12:58 +0200
Re: Adjusting printf() rounding Geoff <geoff@invalid.invalid> - 2022-04-09 08:45 -0700
Re: Adjusting printf() rounding Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-04-09 13:05 -0700
Re: Adjusting printf() rounding red floyd <no.spam.here@its.invalid> - 2022-04-09 13:36 -0700
Re: Adjusting printf() rounding Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-09 16:08 -0700
Re: Adjusting printf() rounding Manfred <noname@add.invalid> - 2022-04-08 21:30 +0200
Re: Adjusting printf() rounding "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-04-09 10:11 +0200
Re: Adjusting printf() rounding Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-10 16:39 +0300
Re: Adjusting printf() rounding Sams Lara <samlara622@gmail.com> - 2022-04-10 18:36 +0100
Re: Adjusting printf() rounding Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-10 21:50 +0300
Re: Adjusting printf() rounding Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-09 09:05 -0700
Re: Adjusting printf() rounding Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-09 09:10 -0700
csiph-web