Re:Poll: How many programmers don't know about bit-wise oper...
by justincormack on Sunday April 07, 2013 @06:52AM
(#5506766)
Perfomance uses are pretty pointless now, as I discovered ten years ago when I found that gcc could turn masked shifts into a native rotate. So for multiply or divide just do so. Obviously where the underlying ops are xor etc, you use them. Most of the time I find myself using the for masking flags in system calls nowdays though and similar.
Re:Poll: How many programmers don't know about bit-wise oper...
by saravk on Sunday April 07, 2013 @06:58AM
(#5506777)
This is where macros (C) come in to play. Using macros (do all the bit shifting and masking inside) you can write very human readable code that is easy to maintain and while at the same time offers all the advantages of using bit-masks.
The major advantage of bitwise operators for me is the memory savings that come with them. I used to write the route calculation algorithms for routers and every bit/byte save had an tremendous impact on the total capacity of the router. We use bitfields to set and store various things from simple flags to multi-bit values, all inside a single integer variable.
Re:Poll: How many programmers don't know about bit-wise oper...
by anigbrowl on Sunday April 07, 2013 @08:55PM
(#5509438)
Great point and excellent context.
Re:Poll: How many programmers don't know about bit-wise oper...
by thethomaseffect on Sunday April 07, 2013 @06:40AM
(#5506751)
This post illustrates my sentiment too. It's great fun to try and be clever but unless they're necessary they're probably a bad idea.
Great question, I hope this stimulates some discussion.