4 ms·
> You'd never want to use this approach at all in a production system Actually it's not less useful than the code the compilers you depend on use all the time.
by acqq 11y ago
> You'd never want to use this approach at all in a production system
Actually it's not less useful than the code the compilers you depend on use all the time. They really depend on such "bit twiddles." Guy Steele agrees too, read his foreword to the "Hacker's Delight," a whole book about such functions:
http://www.hackersdelight.org/foreword.pdf http://www.hackersdelight.org/foreword.pdf
- Splines 11y agoThe difference being that the compiler knows what sort of bit-twiddling it should be doing and what sort of bit-twiddling it should not be doing. I would not use this code without being very thoughtful and intentional about where it was being used.
- acqq 11y ago> I would not use this code without being very thoughtful and intentional about where it was being used. Sure, definitely not for everybody and every occasion. It's a platform dependent code. See my comment to cnvogel and look at his implementation for an example.