[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic pow results incorrect in arithmetic expansion.
From: |
Oğuz |
Subject: |
Re: Arithmetic pow results incorrect in arithmetic expansion. |
Date: |
Sat, 9 Jan 2021 07:22:13 +0200 |
9 Ocak 2021 Cumartesi tarihinde Hyunho Cho <mug896@gmail.com> yazdı:
>
> i have tested below in gnome calculator, Qalculate, gawk, perl
> and all results in -4 but bash is 4
>
> $ awk 'BEGIN { print -2 ^ 2 }'
> -4
>
> $ perl -E 'say -2 ** 2'
> -4
>
> $ 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:
$ echo $((16#-10))
-10
$ echo $((-16#10))
-16
--
Oğuz