• <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ōu)先級

            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
            異或,即
            參與運算的位不同時其結果是1,否則結果為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的二進制:0b
            '100'

            將x的2位置為0,其它位保留不變.
            int x=7;    //0b'111'
            &=~4;        //結果: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)先級 運算符 含義 參與運算對象的數(shù)目 結合方向
             1 ( )
            [ ]
            ->
            .
            圓括號運算符
            下標運算符
            指向結構體成員運算符
            結構體成員運算符

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

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

            <2012年8月>
            2930311234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導航

            統(tǒng)計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            久久久久18| 99久久做夜夜爱天天做精品| 国产精品对白刺激久久久| 97久久久久人妻精品专区| 99久久国产热无码精品免费 | 久久婷婷色综合一区二区| 久久综合五月丁香久久激情| 精品多毛少妇人妻AV免费久久| WWW婷婷AV久久久影片| 欧美日韩中文字幕久久久不卡| 亚洲狠狠婷婷综合久久久久| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 国产精品久久久久jk制服| 欧美777精品久久久久网| 久久精品中文字幕大胸| 94久久国产乱子伦精品免费| 久久99精品国产麻豆不卡| 久久久久亚洲Av无码专| 久久亚洲精品无码aⅴ大香| 国产精品日韩欧美久久综合| 亚洲精品乱码久久久久久按摩| 久久综合九色综合久99| 91精品国产色综久久 | 婷婷综合久久狠狠色99h| 久久精品国产清自在天天线 | 精品免费久久久久国产一区| 无码精品久久久久久人妻中字| 午夜视频久久久久一区| 久久久久99精品成人片三人毛片 | 久久亚洲中文字幕精品一区四| 91久久精品国产成人久久| 久久久久中文字幕| 国产精品女同久久久久电影院| 午夜欧美精品久久久久久久| 国产成年无码久久久免费| 精品久久久久久久国产潘金莲| 色99久久久久高潮综合影院| 无码乱码观看精品久久| 久久久黄色大片| 国产午夜福利精品久久2021| 久久国产亚洲精品麻豆|