octave-maintainers
[Top][All Lists]
Advanced

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

Re: format short output with small numbers (bug #56936)


From: Rik
Subject: Re: format short output with small numbers (bug #56936)
Date: Tue, 24 Sep 2019 13:38:33 -0700

On 09/24/2019 11:19 AM, John W. Eaton wrote:
> On 9/23/19 5:14 PM, Rik wrote:
>> All,
>>
>> What should happen when we display small numbers with "format short"
>> (default)?  Should we end up printing a lot of zeros?  That is what happens
>> now.
>>
>> x = [-pi;0;pi];
>> x*1e-6
>> ans =
>>
>>    -0.0000031416
>>                0
>>     0.0000031416
>>
>> In earlier Octave versions we would switch over to scientific notation at a
>> certain point.  These are the results from version 3.4.3
>>
>> octave-3.4.3:5> x*1e-3
>> ans =
>>
>>    -0.0031416
>>     0.0000000
>>     0.0031416
>>
>> octave-3.4.3:6> x*1e-4
>> ans =
>>
>>    -3.1416e-04
>>     0.0000e+00
>>     3.1416e-04
>
> As I recall, Matlab uses a multiplier (Octave's fixed_point_format
> setting that is enabled when using --traditional).  But that doesn't
> account for the case you show above where it may show 0.00000 for small
> values instead of showing any digits.  For example, something like
>
>   fixed_point_format (true);
>   pi * [1e6; 1e-6]
>
> I chose to switch automatically to avoid confusion because people might
> think that "0.00000" is exactly zero.  At that time, I don't remember
> Matlab displaying "0" to mean "exactly zero" (a feature that I like, BTW,
> thanks for making that change).
>
> For those who want the display to be more like Matlab, is it sufficient
> to set fixed_point_format to true?  If so, then I'm not sure that there
> is anything we need to change, unless you are proposing that we enable
> fixed_point_format by default.
>

Answering this and the other questions as well.

First, no, I'm not particularly interested in turning on fixed_point_format
by default.  I think it's okay, and people should have the option if they
want it, but it's not my preferred display.

Second, yes, there has been a change in the way "format short" displays
large values.  I don't think that was intentional, and probably counts as a
regression.

Third, yes, Octave never switches over to scientific notation now for
"format short" which means "pi* [1e7;0;1e-7] " will display awkwardly as

octave:1> pi* [1e7;0;1e-7]
ans =

   31415926.53590
                0
          0.00000

which simultaneously has too many digits for the first entry and too few
for the third entry (so someone might mistake it for zero).

--Rik



reply via email to

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