mirror of
https://github.com/golang/go
synced 2024-11-25 01:08:02 -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",
|
"Title": "The Go Programming Language Specification",
|
||||||
"Subtitle": "Version of September 7, 2012",
|
"Subtitle": "Version of September 12, 2012",
|
||||||
"Path": "/ref/spec"
|
"Path": "/ref/spec"
|
||||||
}-->
|
}-->
|
||||||
|
|
||||||
@ -2874,8 +2874,8 @@ As a consequence, statement <code>*p++</code> is the same as <code>(*p)++</code>
|
|||||||
<p>
|
<p>
|
||||||
There are five precedence levels for binary operators.
|
There are five precedence levels for binary operators.
|
||||||
Multiplication operators bind strongest, followed by addition
|
Multiplication operators bind strongest, followed by addition
|
||||||
operators, comparison operators, <code>&&</code> (logical and),
|
operators, comparison operators, <code>&&</code> (logical AND),
|
||||||
and finally <code>||</code> (logical or):
|
and finally <code>||</code> (logical OR):
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
@ -2918,10 +2918,10 @@ to strings. All other arithmetic operators apply to integers only.
|
|||||||
/ quotient integers, floats, complex values
|
/ quotient integers, floats, complex values
|
||||||
% remainder integers
|
% remainder integers
|
||||||
|
|
||||||
& bitwise and integers
|
& bitwise AND integers
|
||||||
| bitwise or integers
|
| bitwise OR integers
|
||||||
^ bitwise xor integers
|
^ bitwise XOR integers
|
||||||
&^ bit clear (and not) integers
|
&^ bit clear (AND NOT) integers
|
||||||
|
|
||||||
<< left shift integer << unsigned integer
|
<< left shift integer << unsigned integer
|
||||||
>> right 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 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,
|
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
|
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>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -3182,9 +3182,9 @@ The right operand is evaluated conditionally.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
&& conditional and p && q is "if p then q else false"
|
&& conditional AND p && q is "if p then q else false"
|
||||||
|| conditional or p || q is "if p then true else q"
|
|| conditional OR p || q is "if p then true else q"
|
||||||
! not !p is "not p"
|
! NOT !p is "not p"
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user