octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #33104] mat2str returns ugly result (different


From: Jordi Gutiérrez Hermoso
Subject: [Octave-bug-tracker] [bug #33104] mat2str returns ugly result (different to Matlab)
Date: Sun, 17 Apr 2011 18:08:41 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20110327 Firefox/4.0 Iceweasel/4.0

Follow-up Comment #8, bug #33104 (project octave):

Patrick Häcker  wrote:
> I cannot follow the example with 0.69. With 15 digits the applied
> patch is exact (result: '0.69'). Do I miss anything?

It's not exact. It only looks exact. With 0.69, the exact value
represented in memory is
0.689999999999999946709294817992486059665679931640625 =
1553741871442821/2^51, which is closer to 0.6899999999999999 than to
0.69, so by always rounding to 15 decimal digits you're losing a
little precision that you could have saved. Always rounding to 15
digits hides a few details that a lot of people don't understand about
hardware floats at the expense of losing a little precision now and
then. This is fine except when that loss of precision adds up as it
can during a long computation.

As long as you don't use the results of mat2str as anything more than
a human convenience and you don't care about loss of precision,
unilaterally rounding or truncating the result to 15 digits can be
acceptable.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?33104>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]