当前位置:网站首页>The value of integer a after bitwise negation (~) is - (a+1)
The value of integer a after bitwise negation (~) is - (a+1)
2022-07-25 07:40:00 【hnjzsyjyj】
【 Understanding bitwise negation (~) The original code you need to know before 、 Inverse code 、 The complement rule 】
Data is stored in memory in the form of the complement of signed binary numbers . In the binary representation of signed integers , The highest bit is the sign bit ( The positive integer is 0, Negative integer is 1), This is also the origin of signed integer names .
● The original code of a positive number 、 Inverse code 、 The complement is the same .
● The inverse of a negative number is equal to the sign bit of the original code , The rest of you take the opposite ; The complement of a negative number is the inverse plus 1.
【 Examples of bitwise negation operations are as follows 】
negative :-1
Original code :1000 0001
Inverse code :1111 1110 ( The sign bits remain the same )
Complement code :1111 1111 ( The sign bits remain the same )
According to the not :0000 0000 ( The sign bit is also reversed )
Because the sign bit is 0, Is a positive number . Therefore, complement is equal to the value after bitwise inversion 0000 0000, Its decimal system is 0. That is to say -(-1+1)=0
-------------------------------------
negative :-10
Original code :1000 1010
Inverse code :1111 0101 ( The sign bits remain the same )
Complement code :1111 0110 ( The sign bits remain the same )
According to the not :0000 1001 ( The sign bit is also reversed )
Because the sign bit is 0, Is a positive number . Therefore, complement is equal to the value after bitwise inversion 1111 0110, Its decimal system is 9. That is to say -(-10+1)=9
=============================================================================
Positive numbers :1
Original code :0000 0001
Inverse code :0000 0001 ( The sign bits remain the same )
Complement code :0000 0001 ( The sign bits remain the same )
According to the not :1111 1110 ( The sign bit is also reversed )
Because the sign bit is 1, It's a negative number . There are :
Original code :1111 1110
Inverse code :1000 0001 ( The sign bits remain the same )
Complement code :1000 0010 ( The sign bits remain the same )
Therefore, the decimal system corresponding to the complement is -2. That is to say -(1+1)=-2
-------------------------------------
Positive numbers :10
Original code :0000 1010
Inverse code :0000 1010 ( The sign bits remain the same )
Complement code :0000 1010 ( The sign bits remain the same )
According to the not :1111 0101 ( The sign bit is also reversed )
Because the sign bit is 1, It's a negative number . There are :
Original code :1111 0101
Inverse code :1000 1010 ( The sign bits remain the same )
Complement code :1000 1011 ( The sign bits remain the same )
Therefore, the decimal system corresponding to the complement is -11. That is to say -(10+1)=-110 Not a positive number , It's not a negative number . But the operation rule of bitwise negation is the same as above .
Integers :0
Original code :0000 0000
Inverse code :0000 0000 ( The sign bits remain the same )
Complement code :0000 0000 ( The sign bits remain the same )
According to the not :1111 1111 ( The sign bit is also reversed )
Because the sign bit is 1, It's a negative number . There are :
Original code :1111 1111
Inverse code :1000 0000 ( The sign bits remain the same )
Complement code :1000 0001 ( The sign bits remain the same )
Therefore, the decimal system corresponding to the complement is -1. That is to say -(0+1)=-1 Sum up :
Integers a According to the not (~) The value after is -(a+1)
【 reference 】
https://blog.csdn.net/hnjzsyjyj/article/details/125857019
https://blog.csdn.net/hnjzsyjyj/article/details/119720322
https://blog.csdn.net/hnjzsyjyj/article/details/120794381
https://blog.csdn.net/qq_34681580/article/details/115248595
边栏推荐
- Problems in deep learning training and testing: error: the following arguments are required: --dataroot, solution: the configuration method of training files and test files
- [programmer 2 Civil Servant] summary of some common problems about system research
- Acnet: asymmetric convolution for image hypersegmentation (with implementation code)
- How to use kotlin flow in Android projects
- Bingbing's learning notes: classes and objects (Part 1)
- 【Unity入门计划】界面介绍(2)-Games视图&Hierarchy&Project&Inspector
- cesium简介
- Install homebrew, NVM and verdaccio to build a private NPM warehouse
- Learn no when playing 9 | enterprise knowledge management is so simple because it uses
- Learn no when playing 10. Is enterprise knowledge management too boring? Use it to solve!
猜你喜欢

Native form submission data

Configuring WAPI certificate security policy for Huawei wireless devices

Huawei wireless device configuration wpa2-802.1x-aes security policy

cesium简介

Hikaricp connection pool does not operate for a period of time, and the data is automatically disconnected

Introduction to Manhattan distance

Have you got the advanced usage of pytest?

QT学习日记20——飞机大战项目
![[unity introduction plan] interface Introduction (2) -games view & hierarchy & Project & Inspector](/img/b0/ef084f4391795a1369b0f46a2de8d6.png)
[unity introduction plan] interface Introduction (2) -games view & hierarchy & Project & Inspector

nanodet训练时出现问题:ModuleNotFoundError: No module named ‘nanodet‘的解决方法
随机推荐
If Debian infringes the rust trademark, will it be exempted by compromising and renaming?
如何仅用递归函数和栈操作逆序一个栈
10 key points and 5 measures for good project management
2-6. Automatic acquisition
About --skip networking in gbase 8A
Native form submission data
[unity entry program] make my first little game
PADS导出gerber文件
Quickly build a centralized logging platform through elk
UNIPRO multi terminal deployment to meet customers' diversified needs
Pads export Gerber file
Practical operation: elegant downtime under large-scale micro service architecture
[paper notes] next vit: next generation vision transformer for efficient deployment in real industry
9 best engineering construction project management systems
Xinku online | cnopendata shareholder information data of A-share listed companies
【Unity入门计划】基本概念-GameObject&Components
What products and funds should novices invest in first?
Offline base tile, which can be used for cesium loading
用一个栈实现另一个栈的排序
关于GBase 自动关闭连接问题