Go - The amp operator in golang

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I can t really google the name AND NOT and get any useful results, what exactly is this operator, and how could I do this in a language like C? I checked the specification, and there is nothing helpful in there but a list that says its &^ (AND NOT).

Answers

The C equivalent of the Go expression x &^ y is just x & ~y. That is literally "x AND (bitwise NOT of y)".

https://golang.org/ref/spec#Arithmetic_operators https://golang.org/ref/spec#Arithmetic_operators

So if you think of x | y as a way to turn on certain bits of x based on a mask constant y, then x &^ y is doing the opposite and turns those same bits off.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/34459450/the-operator-in-golang

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils