当前位置:网站首页>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

边栏推荐
- LeetCode·124.二叉树中的最大路径和·递归
- 华为交换机配置日志推送
- openvino 安装(01)
- 顺序表的删除,插入和查找操作
- awk of the Three Musketeers of Shell Programming
- 解决“#231-D declaration is not visible outside of function”告警方法
- Consulting cdc 2.0 for mysql does not execute flush with read lock. How to ensure bin
- 线性代数(四)
- When oracle cdc, set the parallelism to 2 and the number of slots to 1, and the final task has only one tm. Is it because oracle does not support concurrency
- `id` bigint(20) unsigned NOT NULL COMMENT 'Database primary key',
猜你喜欢

干货 | 查资料利器:线上图书馆

Using the DatePicker date control, Prop being mutated: "placement" error occurs

小影科技IPO被终止:年营收3.85亿 五岳与达晨是股东

openvino 安装(01)

JVM类加载机制

LeetCode·124.二叉树中的最大路径和·递归

2022年R2移动式压力容器充装考试题库模拟考试平台操作

文献 | 关于心理活动符号学,你知道多少?

栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记

什么是遗留代码:有效地处理遗留代码的8个小贴士
随机推荐
Shell编程三剑客之awk
今天月亮很美
【Web3 系列开发教程——创建你的第一个 NFT(7)】创建一个 NFT DApp,给你的 NFT 赋予属性,例如图片
Ask you guys.The FlinkCDC2.2.0 version in the CDC community has a description of the supported sqlserver version, please
干货 | 查资料利器:线上图书馆
法定代表人和股东是什么关系
webrtc学习--websocket服务器(二) (web端播放h264)
Pulsar中游标的工作原理
如何取得某月的最后一天
2022G3锅炉水处理考试模拟100题及模拟考试
什么是SRM?有什么作用?在企业管理中能实现哪些功能?
【无标题】
电流探头如何设置示波器参数
顺序表的删除,插入和查找操作
#【软件STM32cubeIDE下F103配置uart3+DMA收发+简单数据解析-基础样例】
`id` bigint(20) unsigned NOT NULL COMMENT 'Database primary key',
二进制中负数为何要用补码形式来表示——二进制加减法
文献 | 关于心理活动符号学,你知道多少?
canvas 画布绘制时钟
咨询cdc 2.0 for mysql不执行flush with read lock.怎么保证bin