码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 位运算::Bitwise operation


    最近学习做cf,第一题永远都是该死的Bitwise operation,好好学习了一下位运算的知识。

    NOT:

    The bitwise NOT, or bitwise complement, is a unary operation that performs logical negation on each bit, forming the ones' complement of the given binary value. Bits that are 0 become 1, and those that are 1 become 0. For example:

    按位 NOT或按位补码是一元运算,它对每个位执行逻辑否定,形成给定二进制值的反码。为 0 的位变为 1,为 1 的位变为 0。例如:

    NOT 0111  (decimal 7)
      = 1000  (decimal 8)

    其实也就是,按二进制展开以后对每一位数字进行一个取反的操作。

    结果是二进制的补码再减去一:NOT x = -x − 1.

    AND:

    A bitwise AND is a binary operation that takes two equal-length binary representations and performs the logical AND operation on each pair of the corresponding bits. Thus, if both bits in the compared position are 1, the bit in the resulting binary representation is 1 (1 × 1 = 1); otherwise, the result is 0 (1 × 0 = 0 and 0 × 0 = 0). For example:

       0101 (decimal 5)
    AND 0011 (decimal 3)
      = 0001 (decimal 1)

    也就是说,同一取一,10取0, 00取0.

    OR:

    A bitwise OR is a binary operation that takes two bit patterns of equal length and performs the logical inclusive OR operation on each pair of corresponding bits. The result in each position is 0 if both bits are 0, while otherwise the result is 1. For example:

       0101 (decimal 5)
    OR 0011 (decimal 3)
     = 0111 (decimal 7)

    只要有一个1就是1.

    XOR

    A bitwise XOR is a binary operation that takes two bit patterns of equal length and performs the logical exclusive OR operation on each pair of corresponding bits. The result in each position is 1 if only one of the bits is 1, but will be 0 if both are 0 or both are 1. In this we perform the comparison of two bits, being 1 if the two bits are different, and 0 if they are the same. For example:

        0101 (decimal 5)
    XOR 0011 (decimal 3)
      = 0110 (decimal 6)

    只要两个数不同就取1,相同的话就取0.

    cf真的好难啊!!!!

  • 相关阅读:
    【深入理解ES6】函数
    git增加右键菜单
    【优化算法】多目标晶体结构算法算法(Matlab代码实现)
    LDAP+Gitea统一认证Git服务器账户管理openLdap和微软的ad
    彻底解决全局安装权限问题
    xctf攻防世界 Web高手进阶区 web2
    python NumPy入门篇
    mongodb使用debezium
    Docker镜像打包示例
    二、【VUE-CLI】分析脚手架 render
  • 原文地址:https://blog.csdn.net/beloved_yu/article/details/125514616
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号