当前位置:网站首页>Machine level representation of data
Machine level representation of data
2021-10-14 03:04:14 【Programming China】
Representation of unsigned and signed numbers
Fixed point and floating point representations of numbers
Character and Chinese character coding method
Data check code
Numerical data represent
data : Signed number An unsigned number
Signed number : Original code Complement code Inverse code
- Numerical data in a computer
Binary number (B)
Octal number (Q)
Decimal number (D)
Hexadecimal number (H)
Number system representation and conversion
- Unsigned and signed numbers
An unsigned number : All binary bits of the whole machine word length represent numeric bits , Equal to the absolute value of a number
The machine word length is n+1 The representation range of an unsigned number of bits 0~2n+1-1
Signed number : just 、 negative
The machine word length is n+1 The signed number of bits represents the range -2n+1~2n+1-1 8 position (-128-127)
Integers : Sign bit Value bits .
decimal : Sign bit . Value bits
- Original code representation
Positive numbers |
0|X| |
|
negative |
1|X| |
|
special |
|
0.0110 |
0.0110 |
|
-0.0110 |
1.0110 |
|
+0 |
00000 |
0110 |
0110 |
|
-0110 |
10110 |
|
-0 |
10000 |
|
|
|
|
|
|
+0 |
0.0000 |
|
|
|
|
|
|
-0 |
1.0000 |
- Reverse code representation
Positive numbers |
= Original code |
|
negative |
1 |X| Take the opposite |
|
special |
|
0.0110 |
0.0110 |
|
-0.0110 |
1.1001 |
|
+0 |
00000 |
0110 |
00110 |
|
-0110 |
11001 |
|
-0 |
11111 |
|
|
|
|
|
|
+0 |
0.0000 |
|
|
|
|
|
|
-0 |
1.1111 |
- Complement representation
Positive numbers |
= Original code |
|
negative |
1 |X| Take the opposite +1 |
|
special |
|
0.0110 |
0.0110 |
|
-0.0110 |
1.1010 |
|
+0 |
00000 |
0110 |
00110 |
|
-0110 |
11010 |
|
-0 |
00000 |
|
|
|
|
|
|
+0 |
0.0000 |
|
|
|
|
|
|
-0 |
0.0000 |
The original code and complement are interchangeable
X Another way to be negative : The first of the last 1 And to the right 0 remain unchanged , On the left, take the opposite , Sign bit
remain unchanged .
[X] primary =10111001100
[X] back =11000110100
- Comparison of three coding systems
Complement and inverse sign bits can be treated as part of numeric bits , Operate with numeric bits ; However, the sign bit of the original code is not allowed to operate with the numeric bit , It has to be dealt with separately
Fixed point representation and floating point representation of machine numbers -- According to whether the position of the decimal point is fixed
Fixed point representation : The position of all decimal points is fixed
- Fixed point decimals :Xs.X1X2……Xn
Scope of representation :X Maximum positive number =1-2-n X Minimum positive number =2-n
Original code :-(1-2-n)~1-2-n
Complement code :-1~1-2-n
- Fixed point integers :XsX1X2……Xn ( The machine word length has n+1 position )
The original code indicates the range :-(2n-1)~2n-1
The complement indicates the range :-2n~2n-1
Floating point representation
Floating point numbers : The position of the decimal point floats as needed
N=M×rE
- r Cardinal number , Usually r=2
- E It's a step code , Signed integers , It is often expressed by code shift or complement
- M mantissa , Signed decimal number , It is often expressed by original code or complement code
- The bottom of a floating point number is implicit , Does not appear in the whole number of machines
- The sign bit of the order code is es, Order code e The size of is reflected in the number N The actual position of the decimal point in
- The sign bit of mantissa is ms, It is the sign bit of the entire floating point number , mantissa m Represents the precision of the floating point number
The representation range of floating-point numbers
- Normalize floating-point numbers : In order to improve the operation accuracy , We need to make full use of the mantissa significand . That is, the highest digit of the mantissa must be a valid value .
1/2<=|M|<1
- When the mantissa is represented by a complement , The normalized floating-point number shall satisfy that the highest digit of the mantissa is different from the sign bit
|
Truth value |
Order code (E) |
mantissa (M) |
The absolute value is the maximum negative number |
|
01111 |
1.0000 |
The absolute value is the smallest negative number |
|
10000 |
1.1111 |
Normalized absolute minimum negative number |
|
1000 |
1.0111 |
Maximum positive number |
|
01111 |
0.1111 |
Minimum positive number |
|
10000 |
0.0001 |
Normalized minimum positive number |
|
10000 |
0.1000 |
Code shifting representation
In truth X Add an offset value ( constant ), amount to X On the number axis, I shifted a distance in the positive direction .
- [X] move = Offset value +X
- Offset value =2n-1
characteristic :
- highest “0” A negative number , highest “1” It means a positive number
- Shift to full 0 when , His corresponding truth value is the smallest , Shift to full 1 when , The corresponding truth value is the maximum
- The representation of truth zero is unique in code shift ,1000 0000
- The shift maps the truth value to a positive field , Therefore, the code shift can be regarded as an unsigned number , Compare sizes directly according to the unsigned number rule
- The code shift and complement of the same value are opposite except the highest bit , Everyone else is the same
The reason why order code adopts code shift
- The reason why the order code of floating point number adopts code shift , If the order code is large, its corresponding truth value is large , If the order code is small, its corresponding truth value is small
- Simplify the zero judgment circuit in the machine . When the order codes are all zero ( Everyone who shifts the code is 0 when , The corresponding order code value is the smallest ), The mantissa is all zero , Indicates that the machine is zero
Fixed point 、 Floating point representation and fixed point representation 、 Floating point computer
Fixed point 、 The difference between floating point notation
- If the word length is the same , The range represented by floating-point numbers is much larger than that of fixed-point numbers
- Floating point precision decreases , The points on the number axis are arranged more sparsely
- Floating point operations are more complex than fixed-point operations
- Overflow handling : Fixed point operation , The result of the operation is beyond the representation range of the number , There is an overflow , But in floating-point operations , The operation result exceeds the representation range of the mantissa and does not necessarily overflow , Overflow occurs when the order code exceeds the range that can be represented .
Fixed point machine and floating point machine
- Pointing machine : Mainly fixed-point operation , Floating point operation is realized by software
- Pointing machine + Floating point software : Floating point arithmetic unit is a unit specially used for floating point arithmetic
- Floating point machine : With floating-point instructions and basic floating-point arithmetic unit
The representation of non numerical data
Non numeric data is character data , That is, the characters 、 character string 、 Various data such as image symbols and Chinese characters , It is not used to represent the size of the value
Representation of characters and strings
- ASCII Character encoding
Represent a character in seven binary digits , Including ten binary digits (0~9)、52 English capital letters (A-Z,a-z)、34 A special symbol ,3 A control symbol , common 128 Characters
A computer usually stores one character per byte
- String storage
Vector storage method : Occupy a contiguous space in memory , Each byte stores a character code , All elements of the string are physically adjacent . What is actually stored in each byte is the of the corresponding character ASCII code .
Unified code
Unicode: Unified code , A character coding scheme that can accommodate all characters and symbols in the world .
Unicode The basic method : Use one 16 A number of bits to represent each symbol , Can be said 65536 A different character or symbol . It is called the Basic Multilingual plane (BMP), namely UCS-2 code .
USC-4, Can be said 100 More than 10000 custom characters
Representation of decimal and number strings
Coding of decimal numbers
Use four binary numbers to represent one decimal number , Called binary coded decimal numbers , abbreviation BCD code .
BCD The code has a binary form , It retains the characteristics of decimal numbers
Decimal system |
8421 code |
2421 code |
|
0 |
0000 |
0000 |
0011 |
1 |
0001 |
0001 |
0100 |
2 |
0010 |
0010 |
0101 |
3 |
0011 |
0011 |
0110 |
4 |
0100 |
0100 |
0111 |
5 |
0101 |
1011 |
1000 |
6 |
0110 |
1100 |
1001 |
7 |
0111 |
1101 |
1010 |
8 |
1000 |
1110 |
1011 |
9 |
1001 |
1111 |
1100 |
Decimal string
- Uncompressed decimal string : A byte that holds a decimal number or symbol ASCII-7 code ( A byte =8 Bit binary number 1Byte=8bit)
- Compressed decimal string : One byte can hold two bits BCD A decimal number represented by a code , Save storage space , Convenient for direct decimal arithmetic operation
Examples of data representation in modern microcomputer systems
Most modern microcomputer systems use Intel Series microprocessors , structure :IA-32 structure
IA-32 Structure basic data type : byte (8 position )、 word (16 position )、 Two words (32 position )、 Four words (64 position )、 Double four characters (128 position )
- Unsigned integer :
- byte :0~255
- word :0~65535
- Two words :0~2^32-1
- Four words :0~2^64-1
- Signed integers
- byte :-128~127
- word :-32768~32767
- Two words :-2^31~2^31-1
- Four words :-2^63~2^63-1
- Floating point numbers
And IEEE 754 The format specified in the standard directly corresponds to
- The pointer is the address of the main memory unit ,IA-32 Structure defines two types of pointers : Near pointer (32 position ) And the far pointer (64 position )
- String data : Including bit string 、 Byte string 、 String and double string . A string can contain from one byte to 4GB The content of .
- BCD Count :IA-32 In structure BCD Code actually means 8421 code
版权声明
本文为[Programming China]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/10/20211002145822814u.html
边栏推荐
- Can Alipay earn money through advanced management? What is Alipay's advanced financial return?
- Cadre de développement Android MVP, résumé de l'entrevue
- Go Connect MSSQL Server Database [Pit encountered]
- Is Alipay robust financial security? Is there a risk?
- How does Alipay get money from advanced financial management? Is Alipay reliable in financing?
- How to redeem Alipay's advanced financial management? How is Alipay's advanced financial management closed?
- Does Alipay's prudent financial accounting lose its principal? Which is good for Alipay's prudent financial management?
- How to manage Alipay's robust financial management? Is Alipay reliable financing reliable?
- How do you collect Alipay gold tickets? How can Alipay gold ticket be closed?
- How can financial management Xiaobai get started easily through these methods
猜你喜欢
-
What is stock repurchase and why
-
Are stock analysts reliable? What professional skills do stock analysts need to master
-
What is the meaning of yesterday's trading performance? What do you think
-
Luogu p4211 [lnoi2014] LCA problem Explanation
-
Écrire un seul test avec une valeur de retour nulle
-
How much money can an ordinary person earn in a day
-
What stocks are there in financial stocks? When is the market better
-
Can I buy the stocks that rose yesterday? Analyze from different situations
-
Overview of Huaxia return hybrid a fund
-
Does the subscription of new shares of Beijing stock exchange need market value? What are the conditions
随机推荐
- How much is the P / E ratio in the normal range? Are the P / E ratios of different industries the same
- What is the normal turnover rate? The answer is this
- Is the interest rate of small bank deposits high and safe? Will it break even?
- Where is the current product with a yield of 4% of Huatong bank? How to calculate the interest withdrawn in advance?
- Which bank is Fu e deposit? Is the annual interest rate of fue deposit s (5 years) as high as 4% safe?
- 2020-11-17
- Ruby‘s Adventure: 2D Beginner 一、 Unity入门
- 团队项目(一)(江山代有才人秃队)
- 好代码是管出来的——使用Jenkins搭建CI服务器
- No buffer space available tcp协议无法释放问题
- 解决:【安全警报】该站点安全证书的吊销信息不可用,是否继续?
- 脑机接口数据分析工具EEGLAB01---安装eeglab
- Projet Open Source: Découvrez comment résoudre l'ensemble du processus de développement et de déploiement en 10 minutes!
- HTV camera RTSP Video Streaming in High version Google Chrome Zero Delay play Effect Demonstration video, support for h.265 Format
- Why do small banks have higher interest rates than large banks? Why don't everyone want to deposit in a small bank?
- Why do small banks have high interest rates? Are small bank deposits risky?
- How about Huatong bank Fu e deposit s (1 year)? Is the income high?
- What are the stock group teacher brainwashing scams? Can the money lost be recovered?
- How does wechat finance make money? How to make money on wechat?
- Has Chao Zhaojin ever lost money? What are the advantages?
- Can Laobaigan liquor stock still rise? Is Laobaigan wine worth long-term investment
- How about rely on smart phone stock? Thousands of shares and thousands of comments of rely on smart electronics
- Is Fangda carbon stock worth holding for a long time? Future market trend of Fangda carbon stock
- Can green water source stocks be held for a long time? Why don't blue water stocks rise
- 腦機接口數據分析工具EEGLAB01---安裝eeglab
- 解决:【安全警報】該站點安全證書的吊銷信息不可用,是否繼續?
- Outil d'analyse des données de l'interface cerveau - ordinateur eeglab01 - - - installation eeglab
- Résolution: [alerte de sécurité] l'information sur la révocation du certificat de sécurité de ce site n'est pas disponible. Voulez - vous continuer?
- Aucun protocole TCP disponible dans l'espace tampon ne peut libérer le problème
- Le bon Code est géré - - construire un serveur ci en utilisant Jenkins
- Projet d'équipe (1) (équipe chauve de Jiangshan Dai Youcai)
- Ruby 's Adventure: 2D Beginner I, Unity Starting
- 17 novembre 2020
- Will Yonghe Zhikong stock rise? Analysis on stock value of Yonghe intelligent control
- Is Yingjia gongjiu stock suitable for long-term holding? Thousands of shares and thousands of comments on Yingjia gongjiu stock
- How about Xingwang Ruijie stock? STARNet Ruijie stock thousands of shares and thousands of comments
- How about Yunhai metal stock? Yunhai metal stock thousand shares thousand comments
- Why doesn't TCL technology stock rise? Reasons for TCL technology stocks falling every day
- High quality low price stocks currently at the bottom (list of high quality low price stocks below RMB 10)
- 10 bull stocks with the largest increase in 2021 (demon stocks with a 10 fold increase this year)