当前位置:网站首页>Why are negative numbers in binary represented in two's complement form - binary addition and subtraction
Why are negative numbers in binary represented in two's complement form - binary addition and subtraction
2022-08-10 05:03:00 【Ghost Rider】
Article table of contents
Related Notes
Negative representation of byte data type in Java—complement representation
Body
A little explanation of why negative numbers of binary data types are represented in two's complement form
The editor's purpose is to do binary addition and subtraction
Authentication
Use source code
1+(-1)
Obviously the answer is wrong
Use two's complement
1+(-1)
Of course, we need multiple verifications, such as 5-3
Verification successful
That's it, it may seem strange and incomprehensible, but this representation is actually very rigorous and correct, isn't it amazing?
Note
If we use out-of-range binary addition and subtraction, such as 127 + 1
127 + 1
边栏推荐
- 一篇文章掌握整个JVM,JVM超详细解析!!!
- 暑期学前作业
- flinkcdc 读取pgsql 的时间被放大了 有大佬知道咋回事吗 gmt_create':1
- About the problem that the mongodb driver count method of rust cannot be used with the near condition
- @Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法
- tensorflow分词深度学习——影评预测
- 2022 security officer C certificate test and simulation test in shandong province
- SQL数据库字段追加到主表
- [Web3 Series Development Tutorial - Create Your First NFT (7)] Create an NFT DApp and assign attributes to your NFT, such as pictures
- 基于 EasyCV 复现 DETR 和 DAB-DETR,Object Query 的正确打开方式
猜你喜欢
随机推荐
【无标题】
兴盛优选监控场景的时序数据库选型与落地实践
解决“File has been changed outside the editor, reload?”提示
【无标题】
小影科技IPO被终止:年营收3.85亿 五岳与达晨是股东
Ueditor编辑器任意文件上传漏洞
今天月亮很美
EasyGBS连接mysql数据库提示“can’t connect to mysql server”,该如何解决?
【LeetCode】41、 缺失的第一个正数
SQL database field to append to main table
The time for flinkcdc to read pgsql is enlarged. Does anyone know what happened? gmt_create':1
B+树与B树的区别、Hash索引与B+树索引的区别
From entry to mastery of PHPCMS imitation station, Xiaobai is enough to watch this set of courses
释放高通量算力价值潜能 JASMINER持续领跑 Web3 市场
leetcode每天5题-Day10
JS gets the year, month, day, time, etc. of the simple current time
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
什么是SRM?有什么作用?在企业管理中能实现哪些功能?
JVM内存模型
cmake