News for hackers. Stuff that matters.
Re:A Bit Overcomplicated by NwtnsMthd on Thursday August 05, 2021 @05:14PM (#28079947)
With a DSP core it often gets even better, the bit shift might be free. Say you have the instruction ACC = ACC + P << PM, that could compile to a single instruction, if you're not writing assembly directly.

Additionally if you're ever working directly with hardware, writing drivers, or firmware, bit-shift operations are often the best (and most common) way to get stuff done.

Re:A Bit Overcomplicated by BulgarianIdiot on Thursday August 05, 2021 @07:14PM (#28081294)
I wouldn't call it better because CPUs have a similar "sum and multiply" instruction, and GPUs are pretty much made of such units.

The problem with bitshifting is that it's just a special case of multiplication and division. So if you want your hardware utilized, you don't scale bitshifts, that'd be largely useless. You scale multiplication and division, and this is what modern hardware does.

Bitshifting is very simple in terms of hardware, but scale beats simplicity.

Re:A Bit Overcomplicated by rasz on Thursday August 05, 2021 @06:44PM (#28081032)