原创 短小精悍的BIT TWIDDING HACKS

2011-4-9 20:55 2468 7 7 分类: 软件与OS

引用:

下面地址:

http://www-graphics.stanford.edu/~seander/bithacks.html#ParityNaive


介绍在程序开发中,需要对位进行特别操作的 精悍算法和技巧!

、对此共享给大家!


Bit Twiddling Hacks


Contents

Compute the integer absolute value (abs) without branchingCompute the minimum (min) or maximum (max) of two integers without branchingDetermining if an integer is a power of 2Sign extending Conditionally set or clear bits without branchingConditionally negate a value without branchingMerge bits from two values according to a maskCounting bits set Computing parity (1 if an odd number of bits set, 0 otherwise) Swapping Values Reversing bit sequences Modulus division (aka computing remainders) Finding integer log base 2 of an integer (aka the position of the highest bit set) Find integer log base 10 of an integerFind integer log base 10 of an integer the obvious wayFind integer log base 2 of a 32-bit IEEE floatFind integer log base 2 of the pow(2, r)-root of a 32-bit IEEE float (for unsigned integer r)Counting consecutive trailing zero bits (or finding bit indices) Round up to the next highest power of 2 by float castingRound up to the next highest power of 2Interleaving bits (aka computing Morton Numbers) Testing for ranges of bytes in a word (and counting occurances found) Compute the lexicographically next bit permutation

文章评论0条评论)

登录后参与讨论
相关推荐阅读
用户1546808 2012-05-30 22:47
经常访问的嵌入式网页荟萃
WEB LEVEL         |        COMMENT A                             | AA-                        ...
用户1546808 2012-03-25 13:21
汽车电子 行业的BOOTLOADER 技术解析
随着开发周期的日益缩短,软件开发的方式逐渐转变为动态更新,从而使得汽车电子模块使得顺应时代的潮流。目的: 1) 产品开发周期中,某一阶段需要释放对应的功能需要。 2)应对产品售后阶段,产品...
用户1546808 2012-03-23 08:48
【博客大赛】CANBUS 物理信号的测试?
最近,在一个项目测试中,测试工程师提交一个ISSUE. 发现CANBU S 的物理信号 不服规范。   介绍: 速率:125KHZ. CAN Transceiver: TJA104...
用户1546808 2012-03-23 08:43
汽车零部件的可靠性的反思 (二)
失效分析的三步骤 1. 寻找根源 2. 分析问题 3. 制定措施         samon在一家知名的汽车电子零部件公司做产品设计开发。最近他开发的部件收到客户的失效反馈。客户返...
用户1546808 2012-03-22 19:23
TPMS --不带LFI 的自动定位技术疑问?
最近一个接到一个GLOBAL 的项目,要求不带LFI 的TPMS 系统,实现轮胎的自动定位。 和同事们沟通后,得出需要借用整车的一些其他传感器信息才可以达到,当前TPMS SENSOR 本身要...
用户1546808 2012-02-26 23:03
转发--关于王立军--一个才女的文章
  一点愚见只为军  (一)  本人一介女流,素来相夫教子,对政治本无半点兴趣,前日忽闻立军之事,却心中不免阵痛。往日不论贪官下马还是清官提升,都觉与我一介布衣无关,自觉愚钝不敢妄论国事,...
EE直播间
更多
我要评论
0
7
1
2
3
4
5
6
7
8
9
0
关闭 站长推荐上一条 /3 下一条