Archive

Posts Tagged ‘log2’

log2的快速计算法

May 9th, 2013 8 comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: log2的快速计算法

从erl_mseg.c中摘抄的:

static const int debruijn[32] = {

0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};

#define LOG2(X) (debruijn[((Uint32)(((X) & -(X)) * 0x077CB531U)) >> 27])

供大家参考!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 源码分析 Tags: ,