[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51515] sprintf not rounding correctly
From: |
Andreas Weber |
Subject: |
[Octave-bug-tracker] [bug #51515] sprintf not rounding correctly |
Date: |
Thu, 20 Jul 2017 05:23:25 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 |
Follow-up Comment #1, bug #51515 (project octave):
Octave outputs the same here as a C snippet "printf ("%1.1g\n", 2.5);"
compiled with gcc would do.
See https://www.gnu.org/software/libc/manual/html_node/Rounding.html
----
Round to nearest.
This is the default mode. It should be used unless there is a specific
need for one of the others. In this mode results are rounded to the nearest
representable value. If the result is midway between two representable values,
the even representable is chosen. Even here means the lowest-order bit is
zero. This rounding mode prevents statistical bias and guarantees numeric
stability: round-off errors in a lengthy calculation will remain smaller than
half of FLT_EPSILON.
----
Do you have a description how Matlab does rounding in fprintf/sprintf? Or is
it just because they've linked another C library?
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51515>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #51515] sprintf not rounding correctly, Luis Mendo, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding correctly,
Andreas Weber <=
- [Octave-bug-tracker] [bug #51515] sprintf not rounding correctly, Luis Mendo, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding correctly, Rik, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding as Matlab does, Rik, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding as Matlab does, Luis Mendo, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding as Matlab does, Rik, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding as Matlab does, Pantxo Diribarne, 2017/07/21
- [Octave-bug-tracker] [bug #51515] sprintf not rounding as Matlab does, Rik, 2017/07/21