DEV Community

Discussion on: Bit Hacking with Go

Collapse
 
dieter_be profile image
Dieter Plaetinck

Thanks Vladimir for this overview!
I have 2 comments:

  • there seems to be a typo in the introduction. it says '^&' which should probably be '&^'
  • the example of using 'AND NOT' to clear the 4 LSB's. do people do this? isn't it easier to just 'AND' against 0xF0 ? I tried it and it seems to provide the same outcome play.golang.org/p/UNuy05nI_X

thanks again,
Dieter

Collapse
 
vladimirvivien profile image
Vladimir Vivien

Hi Dieter,
Thanks for taking time to read and asking questions.

  • You are right, it is a typo, it should be &^ (thanks for catching that)
  • yes the AND and &^ have the same effect in some situations as you pointed out. Their usage will depend on context of what you want to achieve and which one makes the expression you are constructing easier.