in reply to Operator Precedence (unary negation and exponentiation)
Python (python -c 'print -2**2') and Ruby (ruby -e 'print -2**2') do it this way, both commands will print -4.
While we are on the subject, what is going on here??
$ perl -le 'print (-2)**2' -2 $
Update: B::Deparse helps sometimes:
$ perl -MO=Deparse -e 'print (-2)**2' print(-2) ** 2; -e syntax OK
The following does work as intended:
$ perl -le 'print((-2)**2)' 4
— Arien
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Operator Precedence (unary nagation and exponentiation)
by tommyw (Hermit) on Jan 14, 2003 at 11:00 UTC | |
by Abigail-II (Bishop) on Jan 14, 2003 at 11:20 UTC | |
by Arien (Pilgrim) on Jan 14, 2003 at 11:39 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2003 at 11:07 UTC | |
by tommyw (Hermit) on Jan 14, 2003 at 13:05 UTC |