[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: display of scalar numeric values onscreen
From: |
Rik |
Subject: |
Re: display of scalar numeric values onscreen |
Date: |
Sat, 21 Sep 2019 16:10:54 -0700 |
On 09/21/2019 05:54 AM, Olaf Till wrote:
> On Fri, Sep 20, 2019 at 11:26:15PM +0100, Michael D Godfrey wrote:
>> Rik,
>>
>> I vote for just one space as you recommend.
>>
>> On 9/20/19 9:52 PM, Rik wrote:
>>> My thought is that leading
>>> spaces don't make sense and should be trimmed to just one space after the
>>> '=' character.
> The extra space seems to be that of a potential 'minus' sign:
>
> octave:1> 1
> ans = 1
> octave:2> -1
> ans = -1
> octave:3> disp (1)
> 1
> octave:4> disp (-1)
> -1
>
> I don't know if that is intentional. But I'd rather leave it so, so
> that a number and its negative are printed aligned.
The only format I'm thinking of modifying is for scalars where there is no
other number to line up against. The format for arrays is chosen in a
separate routine and there it is important to reserve space and line up
numbers. For example,
format
x = [-1;1]
x =
-1
1
In the scalar case, the extra space seems a little strange. It's true that
variables would still line up across octave prompts as you showed above,
but this is for the narrow case where the variable name has exactly the
same length. In general, if programmers are using meaningful variable
names, this won't happen except by chance. As an example, none of the
scalar variables line up in this polar-to-cartesian conversion.
octave:31> rho = 1
rho = 1
octave:32> theta = -30
theta = -30
octave:33> x = rho * cosd (theta)
x = 0.86603
--Rik
signature.asc
Description: OpenPGP digital signature