javaee Learning Log (52): Response object, file download case, verification code case

2023-01-12   ES  

1. Definition of the original code
在这里插入图片描述
2, the characteristics of the original code

(1) The value part of the original code is the absolute value of the number, and the highest bit represents the symbol position.The highest bit is 0 is the positive number, and the highest bit is 1 is negative number

(2) Indicates range: [-127,+127]
在这里插入图片描述
(3) 0 There are two representations: [+0] = 0 000 0000 , [-0] = 1 000 0000

3, the rules of the original code

For example: number6In the computer in the computer, it is expressed as:0 000 0110Among them, the first number0is a symbol,0indicate a positive number,0000110is the number 

 The binary data of6represents. 

 number -6In the computer in the computer, it is expressed as:1 000 0110above is in 

 The original code in the8bit computer indicates that if it is32bit or 

 The16bit computer, the same method is the same, but there are a few more numbers 

 Only0. 

 For example: 
 exist32bit computer number 

 The original code of6indicates:0 000 0000 0000 0000 0000 0000 0000 011016digital in computer 

 The original code of6indicates:0 000 0000 0000 0110

4, the operation of the original code
在这里插入图片描述

Rodcode represents the rules: if it is positive, then the method is the same as the original code;If it is negative, the symbol is unchanged, and the rest are counterproductive, get the back code representation of this number.

For example, numbers68Bit the inverted code in the computer is its original code:0 000 0110Number-68Bit the inverse code in the computer:1 111 1001

1. The concept of supplement code
在这里插入图片描述
2, the characteristics of the supplement code
(1) The only value in the supplement [0 000 0000]
(2) The negative range of the represented code can reach 2n ,[-128,+127]
在这里插入图片描述
(3)No symbols without symbols (used to the highest bit of the supplementary code as the symbol position)

3, supplement for the calculation

All subtraction can be converted to addition, that is, adding a negative number
在这里插入图片描述
4, make up for the rules of the code
supplement is a general way for computers to represent data. The rules are:

If it is a positive number, the method is the same as the original code; if it is a negative number, add the number of numbers to 1 (equivalent to reaction to the original code bit and then add 1 at the lowest position).

For example: number68The supplementary code in the computer is its original code:0 000 0110Number-68Pitch in the computer is:1 111 1010

First of all, we all know that we use decimal numbers in daily life, but use binary in the computer. If you want a computer to calculate the results such as 2 + 3, you must find a way to use binary to represent 2 and 3. But this very simple thing is to do twists and turns.

Scheme 1: Direct statement

For example: directly convert the decimal number into binary numbers.
在这里插入图片描述
But if you think about it, you will find that there is a problem.

How to represent the
在这里插入图片描述
negative number, because there are only 0 and 1 in the computer, and the positive number can only be represented by 0 and 1.

improvement! Intersection

Scheme 2:Original code representation

Use 0 representative + number, 1 representative -number
在这里插入图片描述
Next verify whether this method is feasible:
在这里插入图片描述
Obviously verified, this method is not possible.

So how does the computer represent decimal number? Let’s take a look at the next plan

Scheme 3:supplement code
在这里插入图片描述

So the solution is feasible,Most of the computers are used to represent the number to represent the number
在这里插入图片描述
And, in the form of supplementary code,All subtraction can be converted to addition, that is, add a negative form. Then when designing the CPU hardware circuit, you only need to design the adder circuit. In fact,

TheComputer does only have a magic weapon, and there is no reduction.

Extension: The data range of a byte can be represented?

Obviously the scope of 8-bit supplement: [-128,+127]
在这里插入图片描述

source

Related Posts

linux commonly used instruction collection

How to download with JS for file download

linux simply read and write a file

HSSFWORKBOOK export data to Excel file

javaee Learning Log (52): Response object, file download case, verification code case

Random Posts

Unity Positive hexagonal grid drawing (streamlined version)-code can be reused directly

News article website

Detailed explanation SpringBoot Schedule configuration Amelia

Spring-IOC container-Keke Teacher

In the Vue project, realize the function of closing the browser before the browser, FELIX