Re: Arithmetic pow results incorrect in arithmetic expansion.

2021-01-09 Thread Oğuz
9 Ocak 2021 Cumartesi tarihinde Ilkka Virta  yazdı:
>
> Note that binary minus doesn't really compare here. It has a lower
> precedence, so gives a different result:
>

Yes, you are right, and not only that, but the example I gave doesn't even
work on 5.1.

  $ (( 16#-10 ))
  bash: ((: 16#: invalid integer constant (error token is "16#")


-- 
Oğuz


Re: Arithmetic pow results incorrect in arithmetic expansion.

2021-01-09 Thread Ilkka Virta
On Sat, Jan 9, 2021 at 9:14 AM Robert Elz  wrote:

> Not "all" other shells, most don't implement exponentiation at all,
> since it isn't a standard C operator.
>

Which also means that the statement about the operators being "same as in
the C language" doesn't really help figure out how this particular one
works.
Which is probably why Zsh has explicitly mentioned it.


Re: Arithmetic pow results incorrect in arithmetic expansion.

2021-01-09 Thread Ilkka Virta
On Sat, Jan 9, 2021 at 7:22 AM Oğuz  wrote:

> 9 Ocak 2021 Cumartesi tarihinde Hyunho Cho  yazdı:
> > $ echo $(( -2 ** 2 )) # only bash results in 4
> > 4
> `bc' does that too. Here's another trivial side effect of implementing
> unary minus using binary minus:
>

Note that binary minus doesn't really compare here. It has a lower
precedence, so gives a different result:

$ echo $(( -3 ** 2 ))
9
$ echo $(( 0 - 3 ** 2 ))
-9