spec: clarify that signed integers are permitted as shift counts

In Go1.13 and above, signed integers are permitted as shift counts as long as they are non-negative. However, the list in the "Arithmetic operators" section says shift operators accept "unsigned integer" as of right operands. Replacing this to "integer >= 0" would reduce the misunderstanding that shift operators permit only unsigned integers.

Go1.13 Release Notes: https://golang.org/doc/go1.13
This commit is contained in:
nobishino 2021-02-27 14:20:11 +09:00
parent d9fd38e68b
commit 4f263a48d3
1 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of Feb 24, 2021",
"Subtitle": "Version of Mar 16, 2021",
"Path": "/ref/spec"
}-->
@ -3681,8 +3681,8 @@ The bitwise logical and shift operators apply to integers only.
^ bitwise XOR integers
&amp;^ bit clear (AND NOT) integers
&lt;&lt; left shift integer &lt;&lt; unsigned integer
&gt;&gt; right shift integer &gt;&gt; unsigned integer
&lt;&lt; left shift integer &lt;&lt; integer >= 0
&gt;&gt; right shift integer &gt;&gt; integer >= 0
</pre>