Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document behaviour of -1² in Traps
Closes #971
  • Loading branch information
zoffixznet committed Oct 27, 2016
1 parent 758bcb8 commit 5a5b428
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doc/Language/traps.pod6
Expand Up @@ -334,6 +334,21 @@ statements in other languages like C<return>, C<last> and many others.
}
say f; # OUTPUT«True␤»
=head2 Exponentiation Operator and Prefix Minus
say -1²; # -1
say -1**2; # -1
When performing a
L<regular mathematical calculation|http://www.wolframalpha.com/input/?i=-1%C2%B2>,
the power takes precedence over the minus; so C<-1²> can be written as C<-(1²)>.
Perl 6 matches these rules of mathematics and the precedence of C<**> operator is
tighter than that of the prefix C<->. If you wish to raise a negative number
to a power, use parentheses:
say (-1)²; # -1

This comment has been minimized.

Copy link
@LLFourn

LLFourn Oct 28, 2016

Contributor

You meant 1 not -1 for both of these :)
EDIT: This was already fixed in e10d6e0
oops.

This comment has been minimized.

Copy link
@AlexDaniel

AlexDaniel Oct 28, 2016

Member

It is already fixed in e10d6e0

say (-1)**2; # -1
=head1 Subroutine and method calls
Subroutine and method calls can be made using one of two forms:
Expand Down

0 comments on commit 5a5b428

Please sign in to comment.