bug-bash
[Top][All Lists]
Advanced

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

Re: Arithmetic pow results incorrect in arithmetic expansion.


From: Chet Ramey
Subject: Re: Arithmetic pow results incorrect in arithmetic expansion.
Date: Sun, 10 Jan 2021 14:14:35 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 1/9/21 12:22 AM, Oğuz wrote:

Here's another trivial side effect of implementing
unary minus using binary minus:

     $ echo $((16#-10))
     -10

Since `-' is an operator, this is not unary minus. It's the same as
$(( 16# - 10 )), which bash before version 5.1 helpfully (or not) treats
identically to $(( 16#0 - 10 )). Bash-5.1 requires at least one digit
after the base specification, so this is a syntax error.


     $ echo $((-16#10))
     -16

This is unary minus applied to an integer constant.


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