<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          C++核心準則ES.101:使用無符號類型進行位操作

          共 906字,需瀏覽 2分鐘

           ·

          2020-06-12 23:21

          183853be6c434cd76d93a410ab196bea.webp

          ES.101: Use unsigned types for bit manipulation

          ES.101:使用無符號類型進行位操作


          Reason(原因)

          Unsigned types support bit manipulation without surprises from sign bits.

          無符號類型支持不受符號位干擾的位操作。


          Example(示例)
          unsigned char x = 0b1010'1010;
          unsigned char y = ~x; // y == 0b0101'0101;


          Note(注意)

          Unsigned types can also be useful for modulo arithmetic. However, if you want modulo arithmetic add comments as necessary noting the reliance on wraparound behavior, as such code can be surprising for many programmers.

          無符號類型在模運算時也很有用。然而,如果你想使用模運算的話,增加必要的注釋說明結果會依賴環(huán)繞行為,因為這樣的代碼會讓很多程序員感到迷惑。


          Enforcement(實施建議)

          • Just about impossible in general because of the use of unsigned subscripts in the standard library

          • 基本上不可能,由于標準庫使用無符號數(shù)作為下標。

          • ???



          原文鏈接

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es101-use-unsigned-types-for-bit-manipulation




          覺得本文有幫助?請分享給更多人。

          關注微信公眾號【面向對象思考】輕松學習每一天!

          面向對象開發(fā),面向對象思考!


          瀏覽 39
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  操熟女91 | 免费韩日AA大片一 | 可以看的免费黄色片 | 亚洲第一页在线播放 | 日本视频一区二区 |