• <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>

            天下

            記錄修行的印記

            C++運(yùn)算符及優(yōu)先級(jí)

            Bitwise Operators ( &, |, ^, ~, <<, >> )


            Bitwise operators modify variables considering the bit patterns that represent the values they store.

            operatorasm equivalentdescription
            & AND Bitwise AND  位與
            | OR Bitwise Inclusive OR 位或
            ^ XOR Bitwise Exclusive OR
            異或,即
            參與運(yùn)算的位不同時(shí)其結(jié)果是1,否則結(jié)果為0 。即“相同為0,不同為1”

            ~ NOT Unary complement (bit inversion) 取反
            << SHL Shift Left 左移
            >> SHR Shift Right 右移

            從右開始為0位: 
            7 6 5 4 3 2 1 0
            位與:將某位置為0
            位或:將某位置為1

            4的二進(jìn)制:0b
            '100'

            將x的2位置為0,其它位保留不變.
            int x=7;    //0b'111'
            &=~4;        //結(jié)果:0b'011'

            位或:
            將x的第2位置為1,其它位保留不變.
            int x= 9;    //0b'1001'
            |= 4;        //0b'1101'       

            There is an established order with the priority of each operator, the priority order is as follows: 

            LevelOperatorDescriptionGrouping
            1 :: scope Left-to-right
            2 () [] . -> ++ --
            dynamic_cast static_cast reinterpret_cast const_cast typeid
            postfix Left-to-right
            3 ++ -- ~ ! sizeof new delete unary (prefix) Right-to-left
            * & indirection and reference (pointers)
            + - unary sign operator
            4 (type) type casting Right-to-left
            5 .* ->* pointer-to-member Left-to-right
            6 * / % multiplicative Left-to-right
            7 + - additive Left-to-right
            8 << >> shift Left-to-right
            9 < > <= >= relational Left-to-right
            10 == != equality Left-to-right
            11 & bitwise AND Left-to-right
            12 ^ bitwise XOR Left-to-right
            13 | bitwise OR Left-to-right
            14 && logical AND Left-to-right
            15 || logical OR Left-to-right
            16 ?: conditional Right-to-left
            17 = *= /= %= += -= >>= <<= &= ^= |= assignment Right-to-left
            18 , comma Left-to-right

            優(yōu)先級(jí) 運(yùn)算符 含義 參與運(yùn)算對(duì)象的數(shù)目 結(jié)合方向
             1 ( )
            [ ]
            ->
            .
            圓括號(hào)運(yùn)算符
            下標(biāo)運(yùn)算符
            指向結(jié)構(gòu)體成員運(yùn)算符
            結(jié)構(gòu)體成員運(yùn)算符

            雙目運(yùn)算符
            雙目運(yùn)算符
            雙目運(yùn)算符
            自左至右
            2
            ~
            ++
            --
            -
            (類型)
            *
            &
            sizeof
            邏輯非運(yùn)算符
            按位取反運(yùn)算符
            自增運(yùn)算符
            自減運(yùn)算符
            負(fù)號(hào)運(yùn)算符
            類型轉(zhuǎn)換運(yùn)算符
            指針運(yùn)算符
            取地址運(yùn)算符
            求類型長(zhǎng)度運(yùn)算符
            單目運(yùn)算符 自右至左
            3 *
            /
            %
            乘法運(yùn)算符
            除法運(yùn)算符
            求余運(yùn)算符
            雙目運(yùn)算符 自左至右
            4 +
            加法運(yùn)算符
            減法運(yùn)算符
            雙目運(yùn)算符 自左至右
            5 <<
            >>
            左移運(yùn)算符
            右移運(yùn)算符
            雙目運(yùn)算符 自左至右
            6 <
            <=
            >
            >=
            關(guān)系運(yùn)算符 雙目運(yùn)算符 自左至右
            7 ==
            !=
            判等運(yùn)算符
            判不等運(yùn)算符
            雙目運(yùn)算符 自左至右
            8 &
            按位與運(yùn)算符 雙目運(yùn)算符 自左至右
            9 ^
            按位異或運(yùn)算符 雙目運(yùn)算符 自左至右
            10 |
            按位或運(yùn)算符 雙目運(yùn)算符 自左至右
            11 &&
            邏輯與運(yùn)算符 雙目運(yùn)算符 自左至右
            12 || 邏輯或運(yùn)算符 雙目運(yùn)算符 自左至右
            13 ?: 條件運(yùn)算符 三目運(yùn)算符 自右至左
            14
            +=
            -=
            *=
            /=
            %=
            >>=
            <<=
            &=
            ^=
            |=
            賦值運(yùn)算符 雙目運(yùn)算符 自右至左
            15 , 逗號(hào)運(yùn)算符
            (順序求值運(yùn)算符)
             
            自左至右

            posted on 2010-11-18 14:20 天下 閱讀(504) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C/C++

            <2010年11月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評(píng)論

            久久本道久久综合伊人| 青青草国产精品久久| 久久最近最新中文字幕大全| 欧美综合天天夜夜久久| 精品久久久久中文字| 亚洲性久久久影院| 久久综合综合久久综合| 国产亚洲美女精品久久久久狼| 国产精品欧美亚洲韩国日本久久| 久久最新免费视频| 久久综合国产乱子伦精品免费| 91超碰碰碰碰久久久久久综合| 伊人久久大香线蕉精品不卡| 精品蜜臀久久久久99网站| 久久久久亚洲AV无码专区网站| 久久人人爽人人爽人人爽| 狠狠狠色丁香婷婷综合久久俺| 亚洲精品NV久久久久久久久久 | 久久久久九九精品影院| 7777精品久久久大香线蕉| 国产精品永久久久久久久久久| 久久婷婷五月综合国产尤物app| 无码任你躁久久久久久老妇| 香蕉久久夜色精品国产小说| 人妻丰满AV无码久久不卡| 午夜精品久久久久久影视riav| 国产午夜久久影院| 久久久久久久久久久久中文字幕 | 久久99精品综合国产首页| 伊人久久一区二区三区无码| 国産精品久久久久久久| 久久国产精品久久| 996久久国产精品线观看| 亚洲国产欧洲综合997久久| 中文字幕精品久久久久人妻| 久久人人爽人人澡人人高潮AV| 国产精品99久久精品爆乳| 久久精品www| 久久精品国产精品亚洲| 精品综合久久久久久88小说 | 久久国产精品99国产精|