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


Groups > gnu.bash.bug > #15058 > unrolled thread

Re: Arithmetic evaluation of negative numbers with base prefix

Started byChet Ramey <chet.ramey@case.edu>
First post2019-06-19 10:39 -0400
Last post2019-06-19 10:39 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Arithmetic evaluation of negative numbers with base prefix Chet Ramey <chet.ramey@case.edu> - 2019-06-19 10:39 -0400

#15058 — Re: Arithmetic evaluation of negative numbers with base prefix

FromChet Ramey <chet.ramey@case.edu>
Date2019-06-19 10:39 -0400
SubjectRe: Arithmetic evaluation of negative numbers with base prefix
Message-ID<mailman.454.1560955191.10840.bug-bash@gnu.org>
On 6/17/19 9:30 AM, Jeremy Townshend wrote:

> Ilkka Virta's email helpfully pointed me to a somewhat related debate that
> occurred about 11 months ago.  I agree with your comment in this debate:
> 
>   "There would be a good case for rejecting the '10#' because it's missing
>   the value."

I'll probably do that for bash-5.1. The code is in there and tagged for
later.

> 
> It is this silently proceeding with a plausible (but undesirable) output in
> such cases which is especially concerning.

Trying to be helpful rarely works out in every case.

> I cannot find anywhere else in the manual where the word "number", "numeric
> value" or "integer" excludes values less than zero without explicitly stating
> so.  On the other hand phrases like "[if] ...  number/numeric values less than
> zero", "if ...  [not] a number greater than [or equal to] zero" are used
> repeatedly.  In those cases "number" clearly doesn't exclude those less than
> zero.

I'm not sure how relevant that language is to integer constants in
expressions. I could also note that the language describing the base#n
syntax only talks about digits, letters, `@', and `_'.

The bash definition of arithmetic evaluation is taken from C. That includes
integer constants, and, while the base#value syntax clearly extends the C
definition of a constant,  the `-' (and `+', FWIW) is still an operator as
defined by C.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web