• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 71,  comments - 41,  trackbacks - 0
            ? 2003 by Charles C. Lin. All rights reserved.

            A Problem

            Suppose you have N different items. You wish to assign each item a unique k bit number, so you can refer to each of them by number, but you want to use as few bits as possible. That is, how small can you make k?

            To answer this question, it's useful to think of it from the other side. Suppose you are given k bits. How many different labels could you create?

            With k bits, there are 2k different bitstring patterns. Thus, there are 2k different labels.

            For example, if you have 3 bits, there are 8 possible bitstrings: 000, 001, 010, 011, 100, 101, 110, and 110. Therefore, you can label up to 8 different items with a unique 3 bit value.

            Suppose you wanted to identify 9 different items. 3 bits isn't enough. 4 bits is too many. With 4 bits, you can label 16 different items.

            Nevertheless, you need to use 4 bits. Thus, if you have to label N items with a unique k bit bitstring, and you want to minimize k, then you need to solve:

               N = 2k
            N is fixed. That is, you are specifying N. You want to find out k, realizing that with k bits, there are 2k possible bitstrings.

            To solve the formular, you take log base 2 of both sides. We use lg to represent log base 2.

               lg N = k
            
            Since lg N can be a fraction, and k must be an integer (we can't have fractional bits), then we need to round up.

            So,

               k = ceil( lg N )
            
            the minimum number of bits is the ceiling of lg N which we write as ceil( lg N ).

            So What?

            You might wonder why we care about labelling N different items with as few bits as possible.

            In hardware, everything is basically 0's and 1's. For example suppose you have 16 registers, and you want to select one of them. How would you do it? The sensible way to do it is to give each register a unique k-bit bitstring.

            Using the formula from the last section, we realize that you need ceil( lg 16 ) = 4. You need 4 bits to identify one of 16 different registers.

            You find this happening throughout hardware. You want to identify one of N things, and so you need to use ceil( lg N ) bits to do so.

            posted on 2007-01-23 15:30 Charles 閱讀(130) 評論(0)  編輯 收藏 引用
            <2007年1月>
            31123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            決定開始寫工作日記,記錄一下自己的軌跡...

            常用鏈接

            留言簿(4)

            隨筆分類(70)

            隨筆檔案(71)

            charles推薦訪問

            搜索

            •  

            積分與排名

            • 積分 - 50780
            • 排名 - 448

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品一区二区影院| 久久精品国产99国产电影网| 久久精品无码一区二区日韩AV| 色综合色天天久久婷婷基地| 久久久亚洲精品蜜桃臀| 人妻无码αv中文字幕久久| 久久久国产精品福利免费 | 99久久无色码中文字幕| 狠狠色综合久久久久尤物| 久久WWW免费人成一看片| 成人国内精品久久久久影院| 久久久久18| 免费观看久久精彩视频| 色欲av伊人久久大香线蕉影院 | 中文字幕亚洲综合久久| 久久精品久久久久观看99水蜜桃| 久久九九亚洲精品| 日韩人妻无码精品久久免费一| 久久久久久极精品久久久 | 久久国产成人午夜aⅴ影院| 久久人人爽人人人人片av| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 国产激情久久久久影院| 久久久一本精品99久久精品66 | 久久久精品人妻一区二区三区蜜桃| 国产精品伊人久久伊人电影 | 国内精品久久久久影院亚洲| 久久国产精品免费| 色综合久久中文综合网| 国产一级持黄大片99久久| 麻豆亚洲AV永久无码精品久久 | 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 亚洲∧v久久久无码精品| 久久综合久久综合亚洲| 久久人人爽人人爽人人片AV麻豆 | 99热成人精品免费久久| 亚洲狠狠久久综合一区77777 | 亚洲伊人久久综合影院| 天天做夜夜做久久做狠狠| 欧美激情精品久久久久久久|