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


Groups > gnu.bash.bug > #15585

Re: bug in arithmetic expansion

From Davide Brini <dave_br@gmx.com>
Newsgroups gnu.bash.bug
Subject Re: bug in arithmetic expansion
Date 2019-11-09 16:39 +0100
Message-ID <mailman.1117.1573314001.13325.bug-bash@gnu.org> (permalink)
References <5415801f-6c6e-9664-7747-9adc02a592f8@gsi.de> <1MI5UD-1ifIp305PL-00FFhG@mail.gmx.com>

Show all headers | View raw


On Sat, 9 Nov 2019 11:52:56 +0100, Joern Knoll <J.Knoll@gsi.de> wrote:

> [tplx99]:/the/knoll > echo $((0123))
> 83
> [tplx99]:/the/knoll > echo $((123))
> 123
> [tplx99]:/the/knoll > echo $((01234))
> 668
> [tplx99]:/the/knoll > echo $((1234))
> 1234

If you want to force base 10 interpretation (remember that leading 0 mean
octal in arithmetic context), you need to explicitly tell bash:

$ echo $(( 10#0123 ))
123

--
D.

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


Thread

Re: bug in arithmetic expansion Davide Brini <dave_br@gmx.com> - 2019-11-09 16:39 +0100

csiph-web