Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15050

Re: Arithmetic evaluation of negative numbers with base prefix

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Ilkka Virta <itvirta@iki.fi>
Newsgroups gnu.bash.bug
Subject Re: Arithmetic evaluation of negative numbers with base prefix
Date Fri, 14 Jun 2019 21:30:15 +0300
Lines 23
Approved bug-bash@gnu.org
Message-ID <mailman.93.1560537058.10840.bug-bash@gnu.org> (permalink)
References <20190614141947.GB27242@tower> <a1c88a1c-7127-4df1-f709-dd247c955064@iki.fi>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1560537059 4072 209.51.188.17 (14 Jun 2019 18:30:59 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org, bash@packages.debian.org
To Jeremy Townshend <jeremy.townshend@gmail.com>
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:60.0) Gecko/20100101 Thunderbird/60.7.0
In-Reply-To <20190614141947.GB27242@tower>
Content-Language en-US
X-SASI-RCODE 200
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; h=subject:to:references:from:cc:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding; s=smtp; bh=iwN4XWkBqpPglaq9oeTNaA2OWmEt2Al5kLah8HL8Sj4=; b=eZdw5Fe3j79OagmLCDmBoHfMkbAjoBvptrtSFkBv/8Agt7ycVniVcLM3CwCsInnl6D8muNFEziTBY2oKTNyh2GkRvj8qnbeGW84naQbTnch9D4xs+cfF6WSDm1v0lc5UKU4owAoqp4in7BhLcdXMhJYKlhtVp+bDU0BqmCpuEOCAHoxk04VJcN+JZggbHz4r6LxVXbrtM1gzj1SDGS84cSowOCRKPkrD1Lh01ej/c8r2l79PxcPcOVT+WcGMxmCMl1hGqK8Zq3iOqjpXleH4+MnhlgN09TOvuti3Tq3ITbNS9SiBarLnYesfK1TijTuMtXLCPE6rt5S97Wk9U4m2qw==
X-detected-operating-system by eggs.gnu.org: FreeBSD 8.x
X-Received-From 157.24.2.104
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <a1c88a1c-7127-4df1-f709-dd247c955064@iki.fi>
X-Mailman-Original-References <20190614141947.GB27242@tower>
Xref csiph.com gnu.bash.bug:15050

Show key headers only | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Arithmetic evaluation of negative numbers with base prefix Ilkka Virta <itvirta@iki.fi> - 2019-06-14 21:30 +0300

csiph-web