code for fun

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2013年6月26日

摘要: 本篇文章介绍一个整数的以10为底的对数的整数部分,即对于整数N,求log10(N)整数部分方法一 :unsigned int v; //32位非0整数 int r; // r保存结果int t; //临时变量static unsigned int const PowersOf10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};t = (IntegerLogBase2(v) + 1) * 1233 >> 12; //使用之前介绍过的... 阅读全文
posted @ 2013-06-26 08:57 xueda120 阅读(744) 评论(0) 推荐(0) 编辑