bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: math operations with base#prefix


From: Chet Ramey
Subject: Re: math operations with base#prefix
Date: Mon, 18 Sep 2023 15:28:27 -0400
User-agent: Mozilla Thunderbird

On 9/17/23 3:59 PM, Victor Pasko wrote:
Hi,

Could you please take a look at attached bug.bash.

Maybe, not all math combinations were presented there or the test has
duplications somehow.
Here are results of several runs with test# as argument

All the examples use the base#number syntax, where `base' is a (decimal)
number and `number' is an integer constant in that arithmetic base.

The issues seem to be misunderstandings and unwarranted expectations.
Several of the test cases use (literal) base10#number, which is an obvious
error -- the base is a number and doesn't include the word `base'. Others
seem to assume that the number, which is an integer constant, can include
non-digits that are out of range for the current base.

For instance, when the base is, say, 32, you can use `res1' as an integer
constant, because those are all valid in base 32, which uses
0123456789abcdefghiklmnopqrstuv as `digits' (if I've counted right). In
base 10, those are invalid.

There's also some confusion about word expansion. The arguments to `let'
and the words between $(( and )) undergo the word expansions documented
in the man page under `Arithmetic Expansion' before the expression goes
to the arithmetic evaluator. This means that something like `$base10#$res1'
will expand to a word with the current values of the shell variables
`base10' and `res1' (e.g., `10#010') before the arithmetic evaluator is
invoked.

--
``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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]