Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
what is a &^= b means?
131 views
Skip to first unread message
xie cui
unread,
Apr 24, 2021, 8:42:01 AM
4/24/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
func f(a, b int) int {
a &^= b
return a
}
what is this op (&^=) means?
xie cui
unread,
Apr 24, 2021, 8:46:22 AM
4/24/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
it means OANDNOT!!!
Jan Mercl
unread,
Apr 24, 2021, 8:55:36 AM
4/24/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xie cui, golang-nuts
There is a wonderful source of answers to such questions here:
https://golang.org/ref/spec
Brian Candler
unread,
Apr 24, 2021, 11:17:12 AM
4/24/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
More or less equivalent to:
a = a & (^b)
where & is bitwise AND operator, and ^ is bitwise NOT operator. Upshot: any bit which is 1 in 'b' causes the corresponding bit in 'a' to be set to 0.
Wojciech S. Czarnecki
unread,
Apr 24, 2021, 11:17:28 AM
4/24/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Dnia 2021-04-24, o godz. 05:42:01
xie cui <
cuiw...@gmail.com
> napisał(a):
> what is this op (&^=) means?
This is common idiom for "bit clear" in Go
Chinese:
https://gfw.go101.org/article/operators.html
English:
https://go101.org/article/operators.html
https://golang.org/ref/spec#assign_op
https://yourbasic.org/golang/bitwise-operator-cheat-sheet/
Hope this helps,
--
Wojciech S. Czarnecki
<< ^oo^ >> OHIR-RIPE
Reply all
Reply to author
Forward
0 new messages