mirror of
https://github.com/golang/go
synced 2024-11-22 05:44:41 -07:00
unary ^ update.
[]int -> string is already in the document. DELTA=7 (1 added, 1 deleted, 5 changed) OCL=29622 CL=29631
This commit is contained in:
parent
65ec16b637
commit
d83dc4f5c6
@ -2577,7 +2577,8 @@ follows:
|
|||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
+x is 0 + x
|
+x is 0 + x
|
||||||
-x negation is 0 - x
|
-x negation is 0 - x
|
||||||
^x bitwise complement is m ^ x with m = "all bits set to 1"
|
^x bitwise complement is m ^ x with m = "all bits set to 1" for unsigned x
|
||||||
|
and m = -1 for signed x
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2944,10 +2945,9 @@ uint8(100) * 100 // error, out of range
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The size of the mask used by the unary bitwise complement
|
The mask used by the unary bitwise complement operator matches
|
||||||
operator in a typed constant expression is equal to the size of the
|
the rule for non-constants: the mask is the all 1s for unsigned constants
|
||||||
expression's type. In an ideal constant expression, the bitwise
|
and -1 for signed and ideal constants.
|
||||||
complement operator inverts all the bits, producing a negative value.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -2955,7 +2955,7 @@ complement operator inverts all the bits, producing a negative value.
|
|||||||
uint8(^1) // error, same as uint8(-2), out of range
|
uint8(^1) // error, same as uint8(-2), out of range
|
||||||
^uint8(1) // typed uint8 constant, same as 0xFF ^ uint8(1) = uint8(0xFE)
|
^uint8(1) // typed uint8 constant, same as 0xFF ^ uint8(1) = uint8(0xFE)
|
||||||
int8(^1) // same as int8(-2)
|
int8(^1) // same as int8(-2)
|
||||||
^int8(1) // error, same as 0xFF ^ int8(1) = int8(0xFE), out of range
|
^int8(1) // same as -1 ^ int8(1) = -2
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user