mercury233
V2EX  ›  问与答

位运算中几种匹配方式用英文怎么说?

  •  
  •   mercury233 · Feb 20, 2021 · 1404 views
    This topic created in 1912 days ago, the information mentioned may be changed or developed.
    if ((var1 & 0x1000111) > 0) // 只要匹配任意一位即通过
    
    if ((var1 & 0x1000111) == 0x1000111) // 必须匹配所有位才通过
    
    if (var1 == 0x1000111) // 必须完全一致才通过
    
    2 replies    2021-02-20 14:24:11 +08:00
    GuuJiang
        1
    GuuJiang  
       Feb 20, 2021 via iPhone   ❤️ 1
    不清楚是否存在专有名词,但是如果我自己来命名的话第一个会叫 anyMatch/anySet,第二个会叫 allMatch/allSet,从代表标志位的角度出发更倾向 Set 这组
    ysc3839
        2
    ysc3839  
       Feb 20, 2021   ❤️ 1
    微软的 wil 里有位运算相关的函数
    https://github.com/microsoft/wil/wiki/Bitwise-operation-helpers#flag-inspection

    对于第一种,是 WI_IsAnyFlagSet
    对于第二种,是 WI_AreAllFlagsSet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2957 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:31 · PVG 13:31 · LAX 22:31 · JFK 01:31
    ♥ Do have faith in what you're doing.