Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Low Level Bit Hacks You Absolutely Must Know (http://www.chiefdelphi.com/forums/showthread.php?t=87212)

taichichuan 21-10-2010 11:14

Low Level Bit Hacks You Absolutely Must Know
 
For those software folks who are looking deeper into embedded systems development:

http://www.catonmat.net/blog/low-lev...tely-must-know

Enjoy,

Mike

RyanCahoon 21-10-2010 14:04

Re: Low Level Bit Hacks You Absolutely Must Know
 
Check out Hacker's Delight for even more (crazy) bit hacking algorithms.

--Ryan

lynca 24-10-2010 11:48

Re: Low Level Bit Hacks You Absolutely Must Know
 
Thanks for sharing,

An embedded programming refresher is always useful especially with the growth of graphical programs that abstract away bit level details.

Greg McKaskle 25-10-2010 12:07

Re: Low Level Bit Hacks You Absolutely Must Know
 
Since they are based on discrete and Boolean mathematics, bit hacks are actually equally valid for LV and any language with rich numerical types and operators. It may not be obvious, but the Boolean operators in LV work on all integer types, and make for concise implementation of many of them.

If you like the general bit hacks and truly want to remember and use them well, I encourage you to try your hand at proofs for them. They don't have to be fully rigorous, but that is of course a useful thing to practice too.

Greg McKaskle

EricVanWyk 25-10-2010 12:40

Re: Low Level Bit Hacks You Absolutely Must Know
 
If any of my students use any of these bit hacks without commenting them, I will smack them.

Ether 25-10-2010 12:46

Re: Low Level Bit Hacks You Absolutely Must Know
 
Quote:

Originally Posted by EricVanWyk (Post 978340)
If any of my students use any of these bit hacks without commenting them, I will smack them.

The first 3 deserve maybe only a noogie, don't you think?



EricH 25-10-2010 12:56

Re: Low Level Bit Hacks You Absolutely Must Know
 
Any programmer who doesn't comment his/her work, no matter the project, deserves to be deprived of caffeine for a week or more. If that doesn't do the trick, proceed to the harsher methods... like noogies and smacks with a mouse cord...

Taylor 25-10-2010 13:04

Re: Low Level Bit Hacks You Absolutely Must Know
 
Quote:

Originally Posted by EricH (Post 978342)
Any programmer who doesn't comment his/her work, no matter the project, deserves to be deprived of caffeine for a week or more. If that doesn't do the trick, proceed to the harsher methods...

Isn't caffeine depravation pretty much the harshest method available? Programming is one application where "shoot first, ask questions later" may not apply.

artdutra04 25-10-2010 15:17

Re: Low Level Bit Hacks You Absolutely Must Know
 
Quote:

Originally Posted by EricVanWyk (Post 978340)
If any of my students use any of these bit hacks without commenting them, I will smack them.

But altering register values via bitwise operations in nested ternary commands is so much fun! :rolleyes:

EricVanWyk 25-10-2010 17:27

Re: Low Level Bit Hacks You Absolutely Must Know
 
Quote:

Originally Posted by artdutra04 (Post 978350)
But altering register values via bitwise operations in nested ternary commands is so much fun! :rolleyes:

Smack!

demosthenes2k8 25-10-2010 18:16

Re: Low Level Bit Hacks You Absolutely Must Know
 
artdura04, you're amazing. The only thing I can think to add to that is that it has to be done inside an obfuscated macro using a templated function pointer and several magic numbers.

Robototes2412 25-10-2010 23:01

Re: Low Level Bit Hacks You Absolutely Must Know
 
or you can be a super-meanie and use a classic turing-style method for making a hello world program, like I did:
Code:

#include <stdio.h>
int main(){char* p=new char[1024];++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;while(*p){++p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++p;++*p;++*p;++*p;++p;++*p;--p;--p;--p;--p;--*p;}++p;++*p;++*p;putchar(*p);++p;++*p;putchar(*p);++*p;++*p;++*p;++*p;++*p;++*p;++*p;putchar(*p);putchar(*p);++*p;++*p;++*p;putchar(*p);++p;++*p;++*p;putchar(*p);--p;--p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;++*p;putchar(*p);++p;putchar(*p);++*p;++*p;++*p;putchar(*p);--*p;--*p;--*p;--*p;--*p;--*p;putchar(*p);--*p;--*p;--*p;--*p;--*p;--*p;--*p;--*p;putchar(*p);++p;++*p;putchar(*p);++p;putchar(*p);return 0;}

its evil


All times are GMT -5. The time now is 22:05.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi