[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51515] sprintf not rounding correctly
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #51515] sprintf not rounding correctly |
Date: |
Thu, 20 Jul 2017 11:46:26 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0 |
Follow-up Comment #3, bug #51515 (project octave):
What version of Matlab and what platform (Linux, Mac, Windows) did you test
with? As Andreas indicated, it may vary simply because of the platform and
the underlying C libraries.
Also, could you test the following:
sprintf ('%1.1g|', [2.5, -2.5, 3.5, -3.5])
Finally, as always, if you want a particular result it is best to code for
that rather than rely on implicit and undocumented defaults which could change
from Matlab version to version. In this case, there are functions floor,
ceil, round, fix, and roundb so the programmer can get exactly the desired
rounding behavior. I would recode to
sprintf ('%1.1g', round (x))
if the desired behavior is regular rounding.
_______________________________________________________
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, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding correctly, Luis Mendo, 2017/07/20
- [Octave-bug-tracker] [bug #51515] sprintf not rounding correctly,
Rik <=
- [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