bug-bash
[Top][All Lists]
Advanced

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

Re: Number with sign is read as octal despite a leading 10#


From: Chet Ramey
Subject: Re: Number with sign is read as octal despite a leading 10#
Date: Tue, 10 Jul 2018 23:17:52 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.0

On 7/10/18 4:57 PM, Isaac Marcos wrote:
> Chet Ramey (<address@hidden <mailto:address@hidden>>) wrote:
> 
>     On 7/10/18 2:48 PM, Isaac Marcos wrote:
>     >     That is not an integer constant. Integer constants don't begin
>     with `-'.
> 
> 
> That makes negative numbers invalid.

You need to look at the difference between constants and operators. This is
what allows you to write $(( -a )), for instance.

>     Because of the difference between an operator and a constant. Unary plus
>     and minus have a higher precedence than arithmetic operators. So if you
>     expand the `a' to an expression, which is what happens, the expression
>     consists of an operator (+ or -) and a constant, and that expression has
>     a higher precedence than the +. You might think about why using `$a' in
>     place of the `a' would not work all the time.
> 
> 
> 
> I don't care. All other shells do this correctly. It makes you the only one
> wrong.

"All other shells" is kind of a broad statement.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

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