mirror of
https://github.com/golang/go
synced 2024-11-21 17:34:40 -07:00
spec: make bitwise operators stand out
The (and not) arguably sounds like it is trying to say something - and not what?. Just an idea, won't be hurt if it gets rejected. R=gri, dsymonds, r CC=golang-dev https://golang.org/cl/6498115
This commit is contained in:
parent
452d6b46a3
commit
1b4e37a43c
@ -1,6 +1,6 @@
|
||||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of September 7, 2012",
|
||||
"Subtitle": "Version of September 12, 2012",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
@ -2874,8 +2874,8 @@ As a consequence, statement <code>*p++</code> is the same as <code>(*p)++</code>
|
||||
<p>
|
||||
There are five precedence levels for binary operators.
|
||||
Multiplication operators bind strongest, followed by addition
|
||||
operators, comparison operators, <code>&&</code> (logical and),
|
||||
and finally <code>||</code> (logical or):
|
||||
operators, comparison operators, <code>&&</code> (logical AND),
|
||||
and finally <code>||</code> (logical OR):
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
@ -2918,10 +2918,10 @@ to strings. All other arithmetic operators apply to integers only.
|
||||
/ quotient integers, floats, complex values
|
||||
% remainder integers
|
||||
|
||||
& bitwise and integers
|
||||
| bitwise or integers
|
||||
^ bitwise xor integers
|
||||
&^ bit clear (and not) integers
|
||||
& bitwise AND integers
|
||||
| bitwise OR integers
|
||||
^ bitwise XOR integers
|
||||
&^ bit clear (AND NOT) integers
|
||||
|
||||
<< left shift integer << unsigned integer
|
||||
>> right shift integer >> unsigned integer
|
||||
@ -2981,7 +2981,7 @@ int64 -9223372036854775808
|
||||
If the divisor is zero, a <a href="#Run_time_panics">run-time panic</a> occurs.
|
||||
If the dividend is positive and the divisor is a constant power of 2,
|
||||
the division may be replaced by a right shift, and computing the remainder may
|
||||
be replaced by a bitwise "and" operation:
|
||||
be replaced by a bitwise AND operation:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@ -3182,9 +3182,9 @@ The right operand is evaluated conditionally.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
&& conditional and p && q is "if p then q else false"
|
||||
|| conditional or p || q is "if p then true else q"
|
||||
! not !p is "not p"
|
||||
&& conditional AND p && q is "if p then q else false"
|
||||
|| conditional OR p || q is "if p then true else q"
|
||||
! NOT !p is "not p"
|
||||
</pre>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user