[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 / itvirta@iki.fi
- Re: Arithmetic evaluation of negative numbers with base prefix, (continued)
- Re: Arithmetic evaluation of negative numbers with base prefix, Chet Ramey, 2019/06/14
- Re: Arithmetic evaluation of negative numbers with base prefix, Jeremy Townshend, 2019/06/17
- Re: Arithmetic evaluation of negative numbers with base prefix, Greg Wooledge, 2019/06/17
- Re: Arithmetic evaluation of negative numbers with base prefix, Ilkka Virta, 2019/06/18
- Re: Arithmetic evaluation of negative numbers with base prefix, Chet Ramey, 2019/06/18
- Re: Arithmetic evaluation of negative numbers with base prefix, Greg Wooledge, 2019/06/18
- Re: Arithmetic evaluation of negative numbers with base prefix, Ilkka Virta, 2019/06/18
- Re: Arithmetic evaluation of negative numbers with base prefix, Chet Ramey, 2019/06/19
- Re: Arithmetic evaluation of negative numbers with base prefix, Chet Ramey, 2019/06/19
- Re: Arithmetic evaluation of negative numbers with base prefix, Chet Ramey, 2019/06/19
Re: Arithmetic evaluation of negative numbers with base prefix,
Ilkka Virta <=