bug-bash
[Top][All Lists]
Advanced

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

Re: Arithmetic evaluation of negative numbers with base prefix


From: Ilkka Virta
Subject: Re: Arithmetic evaluation of negative numbers with base prefix
Date: Fri, 14 Jun 2019 21:30:15 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 14.6. 17:19, Jeremy Townshend wrote:
        echo $((10#-1))   # -1 as expected

Earlier discussion about the same on bug-bash:
https://lists.gnu.org/archive/html/bug-bash/2018-07/msg00015.html

Bash doesn't support the minus (or plus) sign following the 10#.
I think the expression above seems to work in this case because 10# is treated as a constant number by itself (with a value of 0), and then the 1 is subtracted.

try also e.g.:

  $ echo $((10#))
  0

        echo $((0-10#-1)) # -1 UNEXPECTED. Would expect 1.

So this is 0-0-1 = -1

--
Ilkka Virta / address@hidden



reply via email to

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