[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic pow results incorrect in arithmetic expansion.
From: |
Ilkka Virta |
Subject: |
Re: Arithmetic pow results incorrect in arithmetic expansion. |
Date: |
Sat, 9 Jan 2021 15:18:33 +0200 |
On Sat, Jan 9, 2021 at 7:22 AM Oğuz <oguzismailuysal@gmail.com> wrote:
> 9 Ocak 2021 Cumartesi tarihinde Hyunho Cho <mug896@gmail.com> 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