This is the world where 1 + 1 = 10 -- binary language

Confucianism benevolence world home, from the rules. War and iron horse pingtian, legal bundles to settle. The Buddha interprets the evil karma and pudu life, and the Tao changes everything forever. What is the head of a hundred schools? And ask what your heart desires. ---- Zhang Feng Jiete fierce "beg" 2019.2.15Copy the code

Zero, preface,

Regarding digitization, the individual thinks that the computer world is a mapping (or sampling or simulation) of the real world. The real world includes objective existence and the derivative of human civilization (natural science and broad literature). Digitization is mapping these to binary data. The views in this paper are a summary of personal experience and are for reference only

In this paper, including
1. Introduce some concepts and personal understanding. 2. Logic operations 4. Character codec 5. Basic data types in JavaCopy the code

A, congenital eight diagrams and smoke beacon fire

First of all, I am not a person who respects and admires art. Taoists believe that everything has a Yin and Yang, just as everything has a 0,1 in the computer world.

For example, the note-taking software THAT I'm using right now, can you imagine that it's made up of a bunch of zeros and ones? However, these zeros and ones can interact according to the operation, as can"Live"The same. Many times I've thought of an application (whether it's a phone, web, or computer) as a stand-alone organism, as opposed to simple organisms that have vital signs. Here's an analogy:Copy the code
Compare the category biological The application
Living space The earth Computer Systems (Mobile phones, Computers and smart Terminals)
resources The earth provides Computer system provision
food Digestible energy body A body of data that can be processed
digestion Raw food –> available energy Native data –> Available data
waste Shi (test to see health condition) Log (analysis to see health)
behavior Singing, doing homework, reading novels… Play music, play video, show novel…
appearance Make up, change hair, change clothes… Beautify your UI, trim your bangs? , in the skin…
The collection Antiques, money, weapons… Cache file cache
The birth of parents Coder
Family advantage Rich second generation? (Financial support) New products from Big Boss (Technical support)
Ecological group of Entertainment, education, student party… Play related, education related, game related…
Widest existence Infinite space (universe) Infinite memory (undescribable)
The lowest form of expression Can’t describe (element/molecule?) 0 s and 1 s

1, congenital gossip (-A great source of brag-)

The tao says: Yi sheng Tai chi, tai Chi sheng two yi, two yi sheng four elephant, four elephant eight diagrams. The innate eight diagrams are still quite fun, as for the nine palaces of Luoshu and Hetu and the acquired eight diagrams…

When viewing Yin (broken horizontal) as 0 and Yang (connected horizontal) as 1, the bottom-up expression of Xia LAN should be familiar to those who have seen it.

Two instruments: a group of Yin and Yang changes Yang 1 Yin 0 four images: add Yin and Yang changes on the two instruments Sun 11 Yang Shaoyang 10 Yang Taiyin 00 Yin Shaoyin 01 Yin Eight Diagrams: Add Yin and Yang changes on the four images: Tian Gan 111 South three connect one gold Sun ze to 110 southeast upper lack two gold sun fire from 101 East middle deficiency three fire Shaoyang Lei Zhen 100 Northeast Yangyu four wood Shaoyang wind Xun 011 southwest lower break five wood Shaoyin water 010 West middle man six water Shaoyin Shan-gen 001 Northwest bowl seven soil Taiyin Dikun 000 North six broken eight soil TaiyinCopy the code

Add Yin and Yang to the eight diagrams to form the 64 hexagrams. If everything is created by Yin and Yang, then our world is also a binary change? Consider the horrors… This is not to confuse, but to illustrate the variability of binary forces


2. Smoke from the beacon fire

The question from elementary school impressed me (I can’t remember the exact data, of course):

A city border defense has six beacon towers, through the smoke to inform the army enemy number, expressed in binary: light cigarette representative 1, no point on behalf of 0, into decimal 1000 times that is the number of the enemy below the enemy to how many people? 110010 = 2^5+2^4+2^1=32+16+2=50Copy the code

This is interesting, came to 50,000 people I can’t write 50,000 in heaven, two states and six points of change, and then combined with the state of the way to obtain, the beacon smoke did achieve the transmission of information but the credit is beacon smoke, is binary? Smoke is just the way, and binary is just the rule.

It is the essence: encoding and decoding, and at one point I wondered why encoding and decoding. Codec seems like a silly thing to do: recognisable information goes all the way round and becomes recognisable again. What's the point of customising the rules for coding like taking a picture and putting it into a jigsaw puzzle and taking the time to put it back together?Copy the code

The first advantage: encryption can not directly identify the information which implies [someone can identify the meaning] in the process of transmission of information to ensure the relative security of the information [to avoid people who do not know the rules to read or modify] the second advantage: Operable this advantage can be said to change an era, is our era of human customized [compiling rules] and [operating system] to be a translator, these two are not human but we have the intelligence: Programmer -> write code -> compile binary -> operating system reads binary instruction -> the key of operating system execution is that [compiled binary] can be executed in [operating system], so that users feel the age of technologyCopy the code

Having said so much, I want to express one point: change can add information


Second, base related

1. I’m with binary
Elementary school to see binary, is not 1 or 0 bai, I have a half probability! Middle school to see binary, feel a little interesting, is not 1 or 0, who wanted to come out, so boring! High school read binary, expressionless... Binary is binary. I don't care. I can count! University to see binary, do not listen to do not listen to, the son of a bitch chant... ! Now look at binary. Oh, philosophy!Copy the code

2. State and change point

The sum of the changes in a mechanism is equal to the number of changes in state

Daoism: State: Yin and Yang point of change: a line such as the eight diagrams is the three variations of Yin and Yang, called the three lines, and the two instruments are the two lines. The 32 bit like an int is 0, 1 kind of change, called 32-bit, Boolean namely one (true or false) | - why state and change so important? Take the beacon fire smoke for example, can we use decimal? Answer: Yes! As long as the rules can be customized, such as nine colors of smoke on behalf of 1~ 9,0 on behalf of the dot so that 10 states can be formed, that is, decimal, 6 beacon towers can represent any of 0~999999, but the cost is too high, the feasibility is very low; Dots and non-dots are two natural states, so why bother with them? 111111 is 63(2^6-1) at most, and 999999(10^6-1) is a huge difference in the amount of informationCopy the code

3. Why do computers have to use binary

Right time, right place, right place

Timing: the advent of the electric age, humans have mastered the use of electricity, mechanical and electric power combination of historical torrent location: binary physics can be realized (high and low level), logical operation ability, structure and operation rules simple and: talented people, each discipline has been born out of a group of masters, academic atmosphere... Binary addition: 0+0=0 1+0=1 0+1=1 1+1=10 Natural and binary multiplication: 0*0=0 1*0=0 0*1=0 1*1=1 Natural orCopy the code

4. Base conversion

Here’s a question to think about: Can all real decimal numbers be converted to binary? Can all other base real numbers be converted to decimal?

4.1. Convert other bases to base 10

One gasification three qing, the formula goes

R: base (base) I: the positional weight of a number: R ^ I n: the number of integer digits -1 m: Decimal digits -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the decimal 345.6 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3 4 5 6 left left left left 3 * 10 * 10 ^ 1 ^ 2 + 4 + 5 * 10 * 10 ^ - ^ 0 + 6 1 300 + 40 + 5 + 0.6 = 345.6 cardinal R=10; n=2; K=3; K=3; K=4; I =1; K=4; I =0; K=5; I =0; K=5; I =-1; 10 ^ 1 K = 6 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 345.6 turn octal decimal -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3 4 5 6 left left left left 3 * 8 * 8 ^ 1 ^ 2 + 4 + 5 * 8 * 8 ^ ^ 0 + 6-1, 192 + 32 + 5 + 0.75 = 229.75 cardinal R=8; n=2; K=3; K=4; I =1; K=4; I =0; K=5; I = 8^1; K=5; I =-1; 8 K = ^ - 1 6 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 11001.1 binary to decimal -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - 1 1 0 0 1 left left left left left left down down down down down 1 * 2 * 2 ^ ^ 4 + 1 + 3 * 2 * 2 ^ ^ 2 + 0 0 1 + 1*2^0 + 1*2^-1 16 + 8 + 0 + 0 + 1 + 0.5 = 25.5 Cardinal R=2; n=4; M = 1 from left to right For 1: I = 4 right: 2 ^ 4 K = 1 for 1: I = 3 right: 2 ^ 3 K = 1 to 0: I = 2 right: 2 ^ 2 K = 0 to 0: right of I = 1:2 ^ 1 K = 0 for 1: I = 0 power: 2 ^ 1 K = 1 for 1: I =-1 weight: 2^-1 K=1 Binary --> decimal: add weightsCopy the code

4.2. Convert decimal to binary
-- -- -- -- -- -- -- -- -- -- -- -- -- -- 49 convert binary decimal -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- a weight 49/2 = 24 · · · · · · 1 2 ^ 0 = 1 24/2 = 12 · · · · · · 0 - 12/2 = 6 · · · · · · 0 = 3-6/2 · · · · · · 0 - l = 1,..., 1 2 ^ 4 = 16 1/2 = 0 · · · · · · 1 2 ^ 5 = 32 - pour take -- -- > 110001: The primary school teacher told me to change like this, and now I don't understand why? A decimal integer can correspond to a binary integer one by one, but what about a decimal? -- -- -- -- -- -- -- -- -- -- -- -- -- -- the decimal 0.8125 convert binary -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - weight 0.8125 * 2 = 1.625 1 ^ 2-1 = 0.5 0.625 * 2= 1.25 12 ^-2=0.25 0.25 * 2= 0.5 0 -- 0.5 * 2= 1 12 ^-4=0.0625 0 * 2=0 0 -- over 0.5+0.25+0.0625 = 0.8125 -- Exactly. The teacher didn't taught -- -- -- -- -- -- -- -- -- -- -- -- -- -- the decimal 0.6531 convert binary -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - weight 0.6531 * 2 = 1.3062 1 12 ^ 3=0.125 0.2248 * 2 = 0.4496 0 -- 0.4496 * 2 = 0.8992 0 -- 0.8992 * 2 = 1.7984 12 ^-6=0.03125.... Infinite 0.5+0.125+0.03125 = 0.65625 ≈ 0.6531 It's infinite, so that's the problem with small numbers in computersCopy the code

4.3. Conversion between binary and octal hex

Decimals are an indelible flaw in binary. Maybe there are infinite non-cyclic decimals in binary. Or maybe I think numbers are beautiful

Each octal number can be represented by three binary numbers: binary 1010111011.1101 visualization 001 010111011.110 100 Octal 1 2 7 3. 6 4 Visualization 0010 10111011.1101 hex 2 11  11 13------>2BB.DCopy the code

Representation of numbers in computers

1. Unsigned

Combined with the smoke of the beacon fire, there are eight beacon towers, and each beacon tower has two states (0,1) that can represent 0~ 2^8-1 positive integers


2. Add symbols

For integers to have a sign, Java byte is with a sign (+ or -), so to deduct a like the beacon fire smoke can not express how many people to the friendly army, can deduct a as a friendly to the army or the enemy to the army, so the seven beacon towers have numerical value, the benefit is the increase in utility, The disadvantage is that the range of numbers is reduced to minus 2^7 to 2^7-1, which is (-128 to 127) positive integers


3. Subtraction: Byte for example

Computers can’t do subtraction directly, but addition can also become subtraction.

In the morning, I took the bus and was so focused on reading the article that TM did two stops. If the bus reached the end point, it would return to the starting point through the wormhole of space-time. . There are 19 stops in the bus, I was at the 18th stop, there are two choices at the 16th stop, --> get down and go back for two stops, 18-2=16 --> the destination can also be seen as 16+19=35 stop 18+? Equals 35, which is 17 more stops and minus 2 has the same effect as plus 17, so we call 17 the complement of minus 2. This is the idea behind computer subtraction. Obviously: in this operation system: the original code -2 complement 17 18-2 = 18+17 can go to the 16th station there are many such periodicity, that is, the head recolumption, clock, week, date, harmonic motion amplitude and so onCopy the code
byte a = 17; byte b = -5; System.out.println(a + b); / / 12Copy the code


4. Decimal representation: float is an example

7.25(decimal)= 111.01(binary) 111.01(binary)=1.1101*2^2(binary) Analog scientific notation Sign bit: 0 order: 2 + 127 -- binary --> 10000001 1101 | - can use the following code in the Java authentication: remember to fill the 32-bitfloatA = 7.25 f; int b=Float.floatToIntBits(a); String string = Integer.toBinaryString(b); System.out.println(string); //0100 0000 1110 1000 0000 0000 0000 0000 0000Copy the code

Iv. Logical control

1. Four bit operators

I just wrote down a few values, and I looked at them…

To: who is 1 to 1 & both or: | as long as one is one of: to take all the bits xor: ^ two examples is different to 1: c = a & b 0000 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 & 0000 0000 0000 0000 0100 0100 1011 0101 [b] 0x000044b5 17589 --------------------------- 0000 0000 0000 0000 0000 0100 1010 0001 [C] 0x000004A1 1185 d = a | b 0000 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 | 0000 0000 0000 0000 0100 0100 1011 0101 [b] 0x000044b5 17589 --------------------------- 0000 0000 0000 0000 0100 0110 1011 1101 [D] 0x000046bd 18109 e = ~a 0000 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 ~ 1111 1111 1111 1111 1111 1001 0101 0110 [e] 0xffffF956-1706 f = a ^ b 0000 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 ^ 0000 0000 0000 0000 0100 0100 1011 0101 [b] 0x000044b5 17589 --------------------------- 0000 0000 0000 0000 0100 0010 0001 1100 [f] 0x0000421c 16924Copy the code

2. Example of verifying the above bit operation in Java
public static void main(String[] args) { int a = 0x000006a9; //0000 0000 0000 0000 0000 0110 1010 1001 int b = 0x000044b5; //0000 0000 0000 0000 0100 0100 1011 0101 int c = 0x000004a1; //0000 0000 0000 0000 0000 0100 1010 0001 int d = 0x000046bd; //0000 0000 0000 0000 0100 0110 1011 1101 int e = 0xfffff956; //1111 1111 1111 1111 1111 1001 0101 0110 int f = 0x0000421c; //1111 1111 1111 1111 1111 1001 0101 0110 System.out.println(a); //1705 System.out.println(b); Println (a & b); // println(a & b); //1185 System.out.println(c); / / 1185 / / person or System. Out. The println (a | b); //18109 System.out.println(d); Println (e); // println(e); //-1706 System.out.println(~a); //-1706 // bit xOR system.out.println (f); //-1706 System.out.println(a ^ b); } / / - 1706.Copy the code

3. Shift operation

Moving n bits to the left is the same thing as multiplying by 2 to the NTH a<

>n

Example: G = a << 4 0000 0000 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 0000 0000 0000 0000 0000 0000 0110 1010 1001 <-- shift 0000 0000 0000 0000 0110 1010 1001 0000 [g] 0x00006a90 27280=1705*2^4 H = a >> 4 0000 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 0000 0000 0000 0000 0000 0000 0110 1010 1001 <-- shift 0000 0000 0000 0000 0000 0110 1010 [g] 0x0000006a 27280=106 ---->[code validation]--------------- int g = 0x00006a90; //0000 0000 0000 0000 0110 1010 1001 0000 int h = 0x0000006a; //0000 0000 0000 0000 0110 1010 1001 0000 System.out.println(g); //27280 System.out.println(a << 4); //27280 System.out.println(h); //106 System.out.println(a >> 4); / / 106Copy the code

4. Several steps to pay attention to:
1. Make two ints worth the lower 8 bits (the last byte) into a short (the lower 8 bits) : Int value & 0x000000FF ---- 0000 0000 0000 0000 0110 1010 1001 [a] 0x000006a9 1705 & 0000 0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 ------------------------------------------------- 0000 0000 0000 0000 0000 0000 1010 1001 [i] 0x000000a9 Take the lower 8 bits and then shift 8 bits to the left: Int value & 0x000000FF 0000 0000 0000 0000 0000 0100 0100 1011 0101 [b] 0x000044b5 17589 & 0000 0000 0000 0000 0000 0000 1111 1111 ------------------------------------------------- 0000 0000 0000 0000 0000 0000 1011 0101 [j] 0x000000b5 0000 0000 0000 0000 1011 0101 0000 0000 [J] left shift 8 bits 0x0000b500 0000 0000 0000 0000 0000 0000 0000 1010 1001 [I] 0x000000a9 + 0000 0000 0000 0000 1011 0101 0000 0000 [j] 0x0000b500 ------------------------------------------------- 0000 0000 0000 0000 1011 0101 1010 1001 0x0000B5A9 Converting to short completes the task :1011 0101 1010 1001 2. If n = 2^ I, x % n = (n-1) &x (x % n = (n-1) &x); if n = 2^ I, x % n = (n-1) &x; int i1 = 255 & x; //===>67444 % 255 int i2 = x % 256; //===>67444 % 256 System.out.println(i1); //166 System.out.println(i2); / / 166Copy the code

Five, character encoding

Have you ever thought about this question? Computer file storage is based on bytes. Why is a byte 8 bits

1. The ASCII

This is I can find the most clear ASCII code table, later have time to draw a (has added TODO matters) ASCII code characters and control characters a total of 128, that is, 2^7, with 7 binary can map analog beacon smoke, mapping numbers by change. Here the characters are mapped, and the idea is the same, that is, to carry information by change

The three positions above (B6, B5, B4) and the lower four positions on the left (B3, B2, B1, B0) form coordinate points, Public static void main(String[] args) {char T ='T'; System.out.println((int)T); //84 System.out.println(Integer.toBinaryString(T)); //1010100} 1010100 There is A one-to-one correspondence between binary and hexadecimal, so 0x54 is equal to 0b1010100. Remember: Character 0:0 x30 character A:0x41 character A: 0x61Copy the code

Standard ASCII code uses seven bits, but one is reserved as a check bit. IBM has expanded the ASCII code, attacking 256 characters, which belongs to extended ASCII code (non-standard).


2. Encoding of Chinese characters (and other language characters)

Unicode uses two bytes, or 16 bits, to map characters, so a total of 2^16 types, or 65, 536

And then you realize it’s still not enough, so you expand? And the UTF-32 must have a capacity of 4,294, 967, 296, but what a waste! I need an “A” in a basket of 128. Can you give me a basket that can hold $4.2 billion? Flattered…

Hence the utF-8

ASCII code table: American standard Information exchange code 1 byte -- use: 7-bit ISO8859-1: Latin code table. European code table 1 byte - use: 8-bit GB2312: Chinese code table for China. 2 bytes -- Use: 16-bit GBK: GB2312 upgrade, add 2 bytes to Chinese -- Use: 16-bit Unicode: INTERNATIONAL Standard Code 2 bytes -- Use: 16-bit UTF-8: Unicode Upgrade can use 1 character, otherwise use 2, if it is not enough, use 3 bytesCopy the code

3. Specify the encoding table to write the file
Public class encoding table test {public static void main(String[] args) throws IOException {OutputStreamWriter OSw = new OutputStreamWriter(new FileOutputStream("UTF-8.txt"),"utf-8");
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("GBK.txt"),"gbk");
        osw.write("Packer toly"); osw.close(); }}Copy the code


4. How does the computer recognize itzhangThe word

Convert this string into a byte array using UTF-8 encoding, and you can see that there are three numbers [-27, -68, -96]. What do these three numbers represent?

String str = "Zhang";
System.out.println(Arrays.toString(str.getBytes("utf-8"))); / / / - 27-68-96Copy the code

Using a calculator to look at the byte binary of a decimal number, you can see:


5. Use different code tables to read tests
InputStreamReader isr_GBK_gbk = new InputStreamReader(new FileInputStream("GBK.txt"),"gbk"); char[] buf = new char[10]; int len = isr_GBK_gbk.read(buf); System.out.println(new String(buf, 0, len)); InputStreamReader isr_GBK_utf8 = new InputStreamReader(new FileInputStream("GBK.txt"),"utf-8"); char[] buf2 = new char[10]; int len2 = isr_GBK_utf8.read(buf2); System.out.println(new String(buf2, 0, len2)); //�ŷ� TOLy InputStreamReader isr_UTF8_utf8 = new InputStreamReader(New FileInputStream("UTF-8.txt"),"utf-8"); char[] buf4 = new char[10]; int len4 = isr_UTF8_utf8.read(buf4); System.out.println(new String(buf4, 0, len4)); Isr_UTF8_gbk = new InputStreamReader(new FileInputStream("UTF-8.txt"),"gbk"); char[] buf3 = new char[10]; int len3 = isr_UTF8_gbk.read(buf3); System.out.println(new String(buf3, 0, len3)); / / Lao 犻  tolyCopy the code

6.Bits Bit and byte

Bits are the building blocks of computers, bytes are the building blocks of files what if bits were the Yin and Yang of 0,1? , byte is 256 hexagrams, and these 256 hexagrams are the smallest unit of the file. 256 hexagrams are how many lines of the hexagram? 8, 8 bits to keep track of these 256 variations and all the files are in bytes, have you seen 10000.5 bytes anywhere?

Byte conversion: 1 B = 8 bits 1 KB = 1024 B = 8192 bits 1 MB = 1024 KB 1 GB = 1024 MB 1TB = 1024 GBCopy the code

7. Visualize the presence of bytes

Take my avatar, 1,153,744 bytes 1.15 million bytes, right? ! That’s more than 9.2 million that’s nearly 100 million beacon towers to get the message out of this picture?

Now let's make an analogy: (from a macroscopic point of view, we don't care about the six of one and the other) human beings consist of about 40 trillion to 60 trillion cells, and they contain about 13 orders of magnitude of cells. 13 orders of magnitude bits are about 12 orders of magnitude bytes -- 12 orders of magnitude bytes are about 1T four orders of magnitude 12: B > KB -- - > MB -- -- -- -- > T > GB as a result, a byte in the hard disk of 1 T feel like the feeling of a cell is to the human body -- -- -- - > [the following statements represent only personal opinion] -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- note: There are only eight bits in a byte (256 variations), but the kinds of changes inside the cell... In general, the diameter of a molecule is on the order of -10. Let's put a molecule in a cube, and the volume is on the order of -30. 10 to 20μm is on the order of magnitude -5. If you think of a cell as a cubic volume the order of magnitude is on the order of magnitude -15, which means that a cell has about 15 orders of magnitude of molecules and if a program is going to form a human system that operates independently, without taking into account the molecular changes, If you can show that molecules require at least 15 orders of magnitude of t-space, a quadrillion terabytes, to accommodate the total changes of a human being, let alone how a quadrillion terabytes of hard drives are made, can you write a program that large? It can be said that human existence is a perfect bug in the universe! -------- Chang Feng Jie-tee-yeol (miscellany)Copy the code

Six, again look at Java’s several data types

1. The Eight Immortals

After a walk above, does it feel more familiar?

Boolean Boolean type 1 byte Byte 1 byte char 2 bytes, unsigned, or Unicode character and integer short 2 bytes, signed, and integer int 4 bytes, signed, and integer long 8 bytes, signed, integerfloatFloating point with four bytes, signed and decimal sign bits: 1bit, order :8bit, mantissum: 23bit double double floating point with eight bytes, signed and decimal sign bits: 1bit, order :11bit, mantissum: 52bitCopy the code

2. The table
type The number of bytes digits The scope of The initial value
boolean 1 8 true/false false
byte 1 8 2^7 ~ 2^7 ~ 1 (-128 ~ 127) 0
char 2 16 0 ~ 2^16-1(0 ~ 65535) null
short 2 16 15-1-2 2 ^ ^ 15 ~ (- 32768 ~ 32717) 0
int 4 32 – 2 ^ 31 ~ 2 ^ 31-1 (2147483648 ~ 2147483647) 0
long 8 64 – 2 ^ 63 ~ 2 ^ 63-1 0L
float 4 32 Plus or minus 1.4 e-45 ~ + / - 3.4028235 e38 0.0 f
double 8 64 1.7976931348623157 e308 e-324 ~ + / - 4.9 mm 0.0 d

3. The above is obtained using the JAVA API

Doesn’t anybody question the minimum value of float? Are you sure?

| - I don't calm the testfloatF = 1.5 f; System.out.println(Float.MIN_VALUE > f); //true| - Float to obtain a minimum valuefloatBig? ---->[Float.java]------------------# appears to be a directly defined constant which is intentional - code comments are the minimum non-zero integer
 public static final floatMIN_VALUE = 0 x0. 000002-126 - f p; / / 1.4 e-45 f | - so strict said scope should be plus or minus, otherwise not rigorous, basically is onlineCopy the code

4. I just love checking

After all, practice is the only criterion for testing truth

floatF = 0.0 00000 00000 00000 00000 00000 00000 00000 00000 00001f; Double d = double d = double d = double d = double d = double d = double d = double 0.000000000000000000000000000000000000000000000000000000000000000000000000000001;Copy the code

Ok, this is not a lot of people, if you read it carefully, it must benefit a lot and I, as the author, benefit even more, to sum up, some things are clear


Postscript: Jie wen standard

1. Growth record and Errata of this paper
Program source code The date of The appendix
V0.1– The 2018-2-15 There is no

Release name: computer world: [the soul of a bit -] rapid link: www.jianshu.com/p/ee74ea725…

2. More about me
Pen name QQ WeChat
Zhang Feng Jie te Li 1981462002 zdl1994328

My github:github.com/toly1994328 Jane books: www.jianshu.com/u/e4e52c116… My nuggets: juejin.cn/user/149189… Personal website: www.toly1994.com

3. The statement

1—- this article is originally written by Zhang Feng Jetelie, please note 2—- all programming enthusiasts are welcome to communicate with each other 3—- personal ability is limited, if there is any error, you are welcome to criticize and point out, will be modest to correct 4—- See here, I thank you here for your love and support