当前位置:网站首页>Introduction to original code, inverse code and complement code
Introduction to original code, inverse code and complement code
2022-07-28 23:10:00 【Cheng shirt ape】
Signed number , The first bit on the left is the sign bit ,0 Being positive ,1 Negative . stay java All of them are signed numbers .
##. Switch relationships
Original code : The leftmost is the sign bit , Use the remaining digits to represent the absolute value ;
Inverse code : Positive sum 0, The inverse code is itself ;
The inverse of a negative number , The sign bits remain the same , The other figures are reversed (0 change 1,1 change 0).
Complement code : Positive sum 0, The complement is itself ;
A negative complement , On the basis of irony , Regardless of sign bit , Last digit plus 1.
##.java Transform in code
Bit operations are available in code , Original code to inverse code , With int Value, for example , if a Is a negative integer , be a The inverse of is :
int b = a ^ Integer.MAX_VALUE;
or int b = -(~a);
notes :java Median operation , Can also do operations on sign bits .
The complement is :b = b-1; // because b It's a negative number , So the last one adds 1, Equal to minus in truth 1.
Truth value : Signed number , Regardless of sign bit , The value of the number composed of the remaining digits , Equal to the absolute value of the truth
With java in byte Type positive numbers as an example :
Decimal system | Original code | Inverse code | Complement code |
1 | 0000 0001 | 0000 0001 | 0000 0001 |
-1 | 1000 0001 | 1111 1110 | 1111 1111 |
0 | 0000 0000 | 0000 0000 | 0000 0000 |
-128(Byte minimum value ) | 1000 0000 | 1111 1111 | 1000 0000 |
127(Byte Maximum ) | 0111 1111 | 0111 1111 | 0111 1111 |
边栏推荐
- HP ProLiant DL380 boot from USB flash drive, press which key
- Morphology of image
- It's settled! All products of Nezha s will be launched on July 31
- Cglib create proxy
- 递归和迭代
- Xinhuazhang announced the completion of more than 200million a-round financing and the comprehensive layout of eda2.0 R & D
- In 2020, the top ten domestic IC design enterprises will be exposed! These five industrial challenges still need to be overcome!
- recursion and iteration
- Thesis reading (0) - alexnet of classification
- Target detection notes SSD
猜你喜欢

Servlet的使用手把手教学(一)

After reading MySQL database advanced practice (SQL xiaoxuzhu)

PCA learning

Simple es highlight practice

Summary of common formula notes for solving problems in Higher Mathematics

The safety dog has been selected into many details of cloud security panorama 2.0

Thesis reading (2) - vggnet of classification

《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》

MySQL数据库的基本概念以及MySQL8.0版本的部署(一)

定了!哪吒S全系产品将于7月31日上市发售
随机推荐
Improvement 11 of yolov5: replace backbone network C3 with lightweight network mobilenetv3
业界首创云原生安全检测双模型!安全狗重磅报告亮相数字中国建设峰会
高等数学解题常用公式笔记总结
无代码开发平台通讯录入门教程
Goer shares and Shanghai Taisi Weida growth cooperation agreement! Special SOC jointly promotes the development of TWS headphones
Is 1E3 a floating point number?
《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
WebApplicationType#deduceFromClasspath
Target detection notes fast r-cnn
即将获售高通、联发科芯片,荣耀要超越华为做国内第一?
[filter tracking] target tracking based on EKF, TDOA and frequency difference positioning with matlab code
MySQL Basics - Introduction and basic instructions
PCA learning
安全狗入选《云安全全景图2.0》多个细项
The US FCC provided us $1.6 billion to support domestic operators to remove Huawei and ZTE equipment
Es learning directory
DirectX repair tool download (where is exagear simulator package)
MySQL foundation - data query
[physical application] atmospheric absorption loss with matlab code
[radar] radar signal online sorting based on kernel clustering with matlab code