当前位置:网站首页>[embedded C foundation] Part 5: original code / inverse code / complement code
[embedded C foundation] Part 5: original code / inverse code / complement code
2022-07-28 13:02:00 【Black cat senior】
1 Concept
Original code
A positive number = Inverse code = Complement code
Inverse code
negative : The sign bits remain the same , Reverse the value bit
Complement code
negative : Counter code plus 1 Get the complement
2 How signed numbers are stored in memory
Signed numbers are converted into binary complements in memory for storage , Unsigned numbers are directly converted to binary storage .
Convert to inverse code , The sign bits remain the same .
Signed number representation 3 Kind of : Original code 、 Inverse code 、 Complement code
constitute : Sign bit + The numerical part consists of
Sign bit :1 negative 0 just
Example 1: The signed number in memory is 1001 0110, What is the corresponding decimal number ?
Be careful : Is a signed number , And the sign bit is 1, Negative numbers , be 1001 0110 Complement this number
So the inverse of the number is 1001 0101, The original code of this number is 1110 1010, namely -106
summary : Signed numbers are stored in memory as complements
Unsigned numbers are directly converted into binary storage in memory
Example 2:
analysis :int Type defaults to the signed type , Signed types are stored in memory in the form of complements ,-1 The complement of is 1111 1111 1111 1111, The first output is zero -1, The second is unsigned , Store in original code in memory , So it is 216-1=65535
边栏推荐
- Storage model: big end and small end
- Cloud native - runtime environment
- Summary: idea problem record
- Introduction to border border attribute
- Datanode data block missing problem finding
- VS1003 debugging routine
- Solution to using json.tojsonstring to display question marks in Chinese in Servlet
- C# 泛型是什么、泛型缓存、泛型约束
- Redefinition problem of defining int i variable in C for loop
- Leetcode94. Middle order traversal of binary trees
猜你喜欢

Merge sort
![[Bi design teaching] STM32 and FreeRTOS realize low power consumption](/img/2b/3af85135e08599aaa425698c0e83aa.png)
[Bi design teaching] STM32 and FreeRTOS realize low power consumption

Remove the plug-in of category in WordPress link

苏黎世联邦理工学院 | 具有可变形注意Transformer 的基于参考的图像超分辨率(ECCV2022))

Multiple items on a computer share a public-private key pair to pull the Gerrit server code

Black cat takes you to learn EMMC Protocol Part 26: hardware reset operation of EMMC (h/w reset)

Linear classifier (ccf20200901)

Problem solving during copilot trial

LeetCode每日一题(2196. Create Binary Tree From Descriptions)

Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property
随机推荐
LeetCode 42.接雨水
企业数字化本质
SSM框架网上书城全套
Kotlin是如何帮助你避免内存泄漏的?
Xampp Chinese tutorial guide
The essence of enterprise Digitalization
Vs code is not in its original position after being updated
Summary: golang's ide:vscode usage
LeetCode84 柱状图中最大的矩形
Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property
Full disclosure! Huawei cloud distributed cloud native technology and Practice
Fundamentals of machine learning - principal component analysis pca-16
Analysis of Andriod low on memory printing principle
Brief introduction to JS operator
[graduation design] oscilloscope design and Implementation Based on STM32 - single chip microcomputer Internet of things
机器学习实战-决策树-22
Black cat takes you to learn EMMC Protocol Part 24: detailed explanation of EMMC bus test program (cmd19 & cmd14)
Ruan Bonan of Green Alliance Technology: cloud native security from the open source shooting range
Code layered management of interface testing based on RF framework
[Bi design teaching] STM32 and FreeRTOS realize low power consumption