What is the method of calculating binary (bin) 10101010 in a computer
Most people do not understand the knowledge points of this article, "what is the method of calculating binary (bin) 10101010 in the computer?" so the editor summarizes the following, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this article. "what is the method of calculating binary (bin) 10101010 in the computer?"
Let's start with the general method of calculation. Anyone who majored in computer science (hey, hey, I am the one) knows that it should be calculated like this:
Remove symbol bits
(B) 10101010 > (b) 00101010
Lower 7-bit inversion
(B) 00101010 > (b) 01010101
Add 1
(B) 01010101 > (b) 01010110
Binary-> decimal
(B) 01010110 > 64164286
The result is-86. How long did it take you?
The above calculation uses binary to decimal and complement code. If you add the decimal to binary operation, it can basically cover most of the related calculations encountered in programming.
If you search for flowers on the Internet, the space alone will scare you.
In fact, the operation speed can be greatly improved by hexadecimal + simple multiplication and division.
Programmers on earth should know that the relationship between binary, hexadecimal, and decimal numbers is as follows:
Binary hexadecimal decimal
0000 00
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 A 10
1011 B 11
1100 C 12
1101 D 13
1110 E 14
1111 F 15
We use the correspondence above to speed up the calculation.
Binary to decimal
1. Convert binary to hexadecimal first
(B) 10101010-> (h) AA
two。 Convert hexadecimal to 10.
(hex) AA > 10x16+10=170
Decimal to binary
Convert decimal to hexadecimal (divided by 16)
170=16x10+10 > (hex) AA
Hexadecimal to binary
(h) AA- > (b) 10101010
Complement code
We already know that (bin) 10101010 is 170. use 256170 to get 86, and-86 is the value when (bin) 10101010 is regarded as an 8-bit signed number.
If the 16-bit complement code is subtracted with 65536. and so on.
The above is about the content of this article on "what is the method of calculating binary (bin) 10101010 in a computer?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.