posts - 23,  comments - 1,  trackbacks - 0
今天看那本讲AMI bios的书,看到上边书有BIOS的前途是如此大好啊,将来的工资能够达到5位数阿。
心里那个爽啊,继续努力搞我那有前途的bios吧。

posted @ 2007-06-06 23:38 yongqing 阅读(333) | 评论 (1)编辑 收藏
     摘要:   阅读全文
posted @ 2007-06-05 17:06 yongqing 阅读(335) | 评论 (0)编辑 收藏
真的非常强烈的推荐这部又声小说《下班抓紧谈恋爱》。
他让我知道了,我到底需要什么样的爱情,什么是爱情,真正的爱情。
两个晚上的时间花的值得。


posted @ 2007-06-01 01:10 yongqing 阅读(182) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2007-05-18 15:34 yongqing 阅读(811) | 评论 (0)编辑 收藏

Bitwise Operations

It's fairly convoluted though very efficient to encode lots of pieces of Boolean information into a single integer variable. Normal arithmetic and logical operations on such integer variables become unintuitive since we're not usually concerned with the value of the variables (e.g., 17) but rather with the status of individual bits (say, the first and fifth bits are set, all other bits are unset).

This page presents some bitwise operations I found useful while writing an extremely CPU-intensive ray-tracer. C syntax is used but the techniques can be applied to other languages including Java, often with only minor syntax changes.

Tests

  • Is a power of two:

        v & (v-1) == 0


  • Has two or more set bits:

        v & (v-1) > 0


  • Has exactly one set bit:

        v && (v & (v-1) == 0) == true


  • Has all specified bits set:

        v & bits == bits


  • Has at least one specified bit set:

        v & bits > 0


Operations

  • Toggle specific bits:

        v ^= b;


  • Set a bit:

        v |= b;


  • Unset a bit:

        v &= ~b;


  • Unset all bits apart from lowest set bit:

        ((v ^ (v-1)) + 1) >> 1


  • Unset the lowest set bit only:

        v &= (v-1)


Other

  • Count number of set bits:

        int n = 0; if (v) do { n++; } while (v &= (v-1)); return(n);


  • Compute log2 of a power of two:

        float x=v; return (*(int*)&x >> 23) - 127;


  • Compute minimum of two signed 32-bit integers:

        j + (((i-j) >> 31) & (i-j))

posted @ 2007-05-18 09:29 yongqing 阅读(233) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2007-04-27 17:21 yongqing 阅读(446) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2007-04-26 10:22 yongqing 阅读(148) | 评论 (0)编辑 收藏
改日细看看,其中两个台湾牛人的blog,其中一个人据说大陆百万年薪都没请动。
另一个连接乃是Linux下面系统hardware manage的一些软件。
http://www.ibiblio.org/pub/Linux/system/hardware/!INDEX.html
http://orzlab.blogspot.com
/http://blog.linux.org.tw/~jserv/
posted @ 2007-04-25 14:05 yongqing 阅读(188) | 评论 (0)编辑 收藏
仅列出标题  下一页

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(2)

随笔分类

随笔档案

文章分类

收藏夹

blog

linux

storage

windows

搜索

  •  

最新评论

阅读排行榜

评论排行榜