bug-bash
[Top][All Lists]
Advanced

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

Re: Arithmetic expression: interest in unsigned right shift?


From: Robert Elz
Subject: Re: Arithmetic expression: interest in unsigned right shift?
Date: Sun, 17 Jul 2022 14:01:22 +0700

    Date:        Sun, 17 Jul 2022 14:13:16 +1000
    From:        Martin D Kealey <martin@kurahaupo.gen.nz>
    Message-ID:  
<CAN_U6MWRovocRJ3si5mdn=vscQBGpt3jgiBfhYFXztJYBiXE3w@mail.gmail.com>

  | At least by explicitly exposing the word size in a controlled manner, we
  | can write code that avoids unintended overflow.

For just getting the word size, a better solution would be to request a
new predefined variable (eg: BASH_ARITH_BITS) which contains the number
of bits used for arithmetic.   Inventing new mechanisms so you can compute
it dynamically is crazy - it will not change while bash is running.

Most of the rest of what you are suggesting doesn't belong in shell arith,
you should be using a language suited to numeric computing (FORTRAN?)
for most of that, not shell scripting.    Use the right tool for the job.

kre




reply via email to

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