Go Operator Precedence

2,197 views
Skip to first unread message

ianeperson

unread,
May 6, 2012, 6:34:10 PM5/6/12
to golang-nuts
The operator precedence in Go is not only shorter than that for C (C+
+, and their various derivatives), it has significant differences:

For example: 3 * 2 << 3 * 2

In Go gives: 96
In C gives: 384

Some care is going to be required when moving code blocks in Go.

DisposaBoy

unread,
May 7, 2012, 12:54:22 AM5/7/12
to golan...@googlegroups.com
The info you're after is in the spec http://golang.org/ref/spec#Operator_precedence

But I'd say just use parentheses, *no-one* is going to understand what the real intent of that code is
 

tungche...@gmail.com

unread,
Oct 23, 2016, 1:37:05 AM10/23/16
to golang-nuts, ian.e...@dedf.co.uk
I would recommend you use bracket no matter on which language,
then people from different language can understand it without risk
Reply all
Reply to author
Forward
0 new messages