Re:20 bit operations programmers should know
by Sambdala on Saturday June 08, 2013 @08:25AM
(#5844688)
Do you (or anyone else) have a good source for someone who wants an introduction to bit operations?
Re:20 bit operations programmers should know
by Jabbles on Saturday June 08, 2013 @08:27AM
(#5844694)
http://graphics.stanford.edu/~seander/bithacks.html
Entertaining book: http://www.amazon.co.uk/Hackers-Delight-2nd-Edition-ebook/dp...
The reference: http://www.amazon.co.uk/The-Computer-Programming-Vol-Combina... Section 7.1.3 Bitwise Tricks and Techniques
Re:20 bit operations programmers should know
by Sambdala on Saturday June 08, 2013 @09:41AM
(#5844836)
Thanks!
Re:20 bit operations programmers should know
by Jabbles on Saturday June 08, 2013 @08:26AM
(#5844693)
It's unclear what language that is. Could that be (well-defined) Java?
Besides, it's also wrong because left shifting a signed integer "into the sign bit" is undefined.
Re:20 bit operations programmers should know
by deletes on Saturday June 08, 2013 @08:30AM
(#5844702)
Author is apparently trying to combine multiple languages.
Maybe well defined in java, definitely not in C.
Re:20 bit operations programmers should know
by Jabbles on Saturday June 08, 2013 @08:35AM
(#5844717)
In the original Chinese article, the languages were actually mentioned. And the one we're discussing is C++. (And so as you point out, wrong.)
It annoys me that this kind of vacuous article is posted. It reminds me of an old rant about Perl tutorials: http://blogs.perl.org/users/mithaldu/2011/10/perl-tutorials-...
Although int has a 32 bit size on almost all systems it is only guaranteed to have a size of 16 bits.
The correct way of getting the size of int is including limits.h ( <climits> ) and looking at the value INT_MAX.