Generally when you ask that question you probably won't need to use them.

The main reasons you would use them:

1. bitflags -- allows to easily specify a set of 8 to 64 elements easily 
(https://play.golang.org/p/DZj9FerK19)
2. fast ways to compute something -- see 
https://graphics.stanford.edu/~seander/bithacks.html, 
http://aggregate.org/MAGIC/
3. packing -- e.g. when you have seven 3 bit numbers then you can fit 21 of 
them into a 64bit number; to pack and extract you would need to use bit 
operations; similarly many packing algorithms use them for that reasons
4. bit parallel operations - when you have several packed numbers you can 
do some operations in bit parallel, e.g. you could add together 16 3bit 
numbers together in two computer cycles using a 64bit number.
5. There are also some algorithms that exploit bit operations, e.g. 
shift-or search http://www-igm.univ-mlv.fr/~lecroq/string/node6.html

+ Egon

On Saturday, 22 July 2017 20:36:14 UTC-7, Alexey Dvoretskiy wrote:
>
> Hello golang-nuts.
>
> I'm new to Go language and have no solid experience with C/C++. 
> I was a database programmer with some Python and I was able to get around 
> without bitwise operators easily.
> Of course, I ran into tons of issues with performance, deployment and 
> other stuff. That is why I switched to Go.
>
> The question is what are practical applications of bitwise operations in 
> Go and when I should use/learn them?
>
> Thanks
> Alex
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to