Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15588
| From | Robert Elz <kre@munnari.OZ.AU> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: bug in arithmetic expansion |
| Date | 2019-11-10 00:14 +0700 |
| Message-ID | <mailman.1124.1573319700.13325.bug-bash@gnu.org> (permalink) |
| References | <1MI5UD-1ifIp305PL-00FFhG@mail.gmx.com> <5415801f-6c6e-9664-7747-9adc02a592f8@gsi.de> <27430.1573319650@jinx.noi.kre.to> |
Date: Sat, 9 Nov 2019 16:39:52 +0100
From: Davide Brini <dave_br@gmx.com>
Message-ID: <1MI5UD-1ifIp305PL-00FFhG@mail.gmx.com>
| 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
But do remember that that form is not portable, and is difficult to
use correctly in the cases that matter (when the actyal number comes
from a variable .. when it is literal, as in all the examples in this
thread, simply omitting the leading 0 is much simpler, and fully portable).
kre
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: bug in arithmetic expansion Robert Elz <kre@munnari.OZ.AU> - 2019-11-10 00:14 +0700
csiph-web