1
0
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:
Russ Cox 2012-09-12 12:05:24 -04:00
parent 452d6b46a3
commit 1b4e37a43c

View File

@ -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>&amp;&amp;</code> (logical and), operators, comparison operators, <code>&amp;&amp;</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
&amp; bitwise and integers &amp; bitwise AND integers
| bitwise or integers | bitwise OR integers
^ bitwise xor integers ^ bitwise XOR integers
&amp;^ bit clear (and not) integers &amp;^ bit clear (AND NOT) integers
&lt;&lt; left shift integer &lt;&lt; unsigned integer &lt;&lt; left shift integer &lt;&lt; unsigned integer
&gt;&gt; right shift integer &gt;&gt; unsigned integer &gt;&gt; right shift integer &gt;&gt; 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">
&amp;&amp; conditional and p &amp;&amp; q is "if p then q else false" &amp;&amp; conditional AND p &amp;&amp; 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>