• <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++運算符及優先級

            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

            優先級 運算符 含義 參與運算對象的數目 結合方向
             1 ( )
            [ ]
            ->
            .
            圓括號運算符
            下標運算符
            指向結構體成員運算符
            結構體成員運算符

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

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

            <2012年6月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            久久亚洲电影| 久久ZYZ资源站无码中文动漫| 久久精品国产亚洲AV大全| 欧美日韩久久中文字幕| 亚洲va中文字幕无码久久| 久久国产精品一国产精品金尊| 国产精品久久久久影院嫩草| 精品久久人人做人人爽综合| 色婷婷噜噜久久国产精品12p| 国产精品一区二区久久精品涩爱 | 久久国产乱子精品免费女| 99久久精品免费国产大片| 久久免费视频1| 国产高潮国产高潮久久久91 | 亚洲国产精品久久久久婷婷老年| 思思久久99热免费精品6| 久久亚洲欧美国产精品 | 久久综合九色综合网站| 久久久久国色AV免费看图片| 欧美亚洲色综久久精品国产| 亚洲?V乱码久久精品蜜桃| 色综合久久中文色婷婷| 亚洲精品无码久久久久去q| 久久久久国产精品嫩草影院| 狠狠色丁香久久婷婷综合五月| 久久影院亚洲一区| 青青青青久久精品国产h| 久久精品国产亚洲AV无码偷窥| 香蕉久久AⅤ一区二区三区| 久久青青草原国产精品免费| 久久无码一区二区三区少妇| 97精品久久天干天天天按摩 | 欧美大战日韩91综合一区婷婷久久青草 | 蜜臀久久99精品久久久久久| 久久国产高清一区二区三区| 久久精品国产半推半就| 国产亚洲精品自在久久| 久久午夜伦鲁片免费无码| 久久精品国产亚洲AV久| AV无码久久久久不卡蜜桃| 国产69精品久久久久观看软件|