I would expect most good programmers to know at least some basic "tricks" though (and would hope they have the sense to not over use them).
Poll: How many programmers don't know about bit-wise operations?
21–30 of 82 posts
Re: Poll: How many programmers don't know about bit-wise operations?
#22Though K&R is on the shelf within reach and I knew it had a good algorithm for counting set bits (ones), I also remembered reading about a more efficient method a while back. The following page covers a number of set bit counting hacks:
Re: Poll: How many programmers don't know about bit-wise operations?
#23"result = bits[3] xor bits2[3]".
Re: Poll: How many programmers don't know about bit-wise operations?
#24I like the elegance of bitwise operations and use them sometimes in signal processing applications to avoid a performance hit, though I'm no expert. But I avoid them in any high level code because a) the compiler is likely going to optimize that anyway and b) to be as human-readable as possible, the code should clearly describe the objective rather than exploit the underlying mechanism. In other words if I want to mu…
Re: Poll: How many programmers don't know about bit-wise operations?
#25Re: Poll: How many programmers don't know about bit-wise operations?
#26Re: Poll: How many programmers don't know about bit-wise operations?
#27I have always wondered why I was taught binary as if they were arrays, but programming languages never allowed me to use bits like arrays. It's always masking and shifting uint16_t or int32_t, instead of what I really want, "result = bits[3] xor bits2[3]".
EDIT: You're moving stuff into and out of registers (typically blocks of specific sizes), but the registers are also not bit-addressable, hence the need for bit-wise manipulation.
Re: Poll: How many programmers don't know about bit-wise operations?
#28I like the elegance of bitwise operations and use them sometimes in signal processing applications to avoid a performance hit, though I'm no expert. But I avoid them in any high level code because a) the compiler is likely going to optimize that anyway and b) to be as human-readable as possible, the code should clearly describe the objective rather than exploit the underlying mechanism. In other words if I want to mu…
Re: Poll: How many programmers don't know about bit-wise operations?
#29"I know about them and could do complex things with them when they're the right tool, but for the kind of programs I write they're never needed."
Re: Poll: How many programmers don't know about bit-wise operations?
#30Hackers Delight! http://www.amazon.com/Hackers-Delight-Edition-Henry-Warren/d...