<> Binary :

<> review :

* regular expression :
* Describes the format of the string content , It is usually used to match whether the content of the string meets the requirements
* regular expression syntax -------------- understand
* String Methods related to regular expressions in :
* matches(): Use the given regular expression to verify whether the current string content meets the requirements , Compliance return true, Non conforming return false
* split(): Splits the current string into parts that satisfy the regular expression , Split into string arrays
* replaceAll(): Replaces the part of the current string that satisfies the regular expression with the specified string , Returns the replaced string
* Object:
* Ancestor , All classes inherit directly or indirectly Object, Everything is object
* There are two methods that are often rewritten :toString() and equals()
* Object Medium toString() Returns the full name of the class @ address , No reference significance , So often rewrite toString() Return the data we need
* Object Medium equals() The address of the object is compared , No reference significance , So often rewrite equals() To compare the properties of the object
* Packaging :
* 8 Packaging category , In order to solve the problem that basic data types cannot participate in object-oriented development
* JDK1.5 introduction : Features of automatic disassembly and assembly box , Allow direct assignment between base type and wrapper class , The bottom layer will automatically supplement the code to complete the conversion
<> note :

<> What is? 2 Base system

*
Counting rule of every two into one

*
How will 2 Binary conversion to 10 Base system ?

* Will one 2 Hexadecimal number each 1 The weight of the position can be accumulated
*
Java All variables \ Constants store 2 Hexadecimal number !

*
Code demonstration :
public class Demo01 { public static void main(String[] args) { /*
1.java During compilation 10 Hexadecimal number compiled as 2 Hexadecimal number , Press 2 Binary operation .java(50) After compilation .class(110010)
2.Integer.toBinaryString() The bottom layer can be 2 Hexadecimal numbers are displayed 3.int Type is 32 position 2 Hexadecimal number , display 2 Automatically omit the high order in hexadecimal number 0
4.System.out.println() take 2 Binary conversion to 10 Binary output */ int n = 50; //110010 System.out.println(
Integer.toBinaryString(n)); //2 Base system n++; //110011 System.out.println(n); //10 Base system
System.out.println(Integer.toBinaryString(n)); //2 Base system } }
<> What is? 16 Base system

* Meet 16 enter 1 Counting rules for
* because 2 Hexadecimal writing is too cumbersome 00000000 00000000 00000000 00110010 So often use 16 Hexadecimal abbreviation 2 Hexadecimal digit
* i shall : take 2 Hexadecimal starts from the lowest bit , each 4 position 2 Hexadecimal abbreviation is 1 position 16 Base system
* Code demonstration :public class Demo02 { public static void main(String[] args) { /*
16 Base system : abbreviation 2 Base system 1)0x yes 16 Binary literal prefix ,0x At the beginning, the compiler follows 16 Binary compilation 2)Java 7 Provided 2 Binary literal prefix
0b---- no need , Usually 16 Base system */ int n = 0x4f057afe; //0x express 16 Base system int m =
0b1001111000001010111101011111110; //0b Represent binary System.out.println(Integer.
toBinaryString(n)); // Press 2 Binary output System.out.println(Integer.toBinaryString(m));
// Press 2 Binary output // conclusion : use 16 In hexadecimal 2 Binary system is more convenient /* 8 Base system : 1) Meet 8 enter 1 Counting rules for 2) prefix 0 Expressed as 8 Base system
3) number :0,1,2,3,4,5,6,7, No, 7 Above figures */ //---- Small interview questions (8 Not usually ) // power 64 8 1 int x = 067;
//0 Opening representation 8 Base system System.out.println(x); // Decimal 55(6 individual 8 add 7 individual 1) } }
<> Complement

*
Signed number processed in computer ( Positive and negative number ) A coding method of ,java The minimum type of complement in is int,32 digit

*
with 4 position 2 Take hexadecimal as an example to explain the coding rules of complement :

* If the calculation exceeds 4 The number of digits will overflow and be discarded automatically , keep 4 The number of digits remains unchanged
* take 4 position 2 Half of a hexadecimal number is used as a negative number
* The highest bit is called the sign bit , High order 1 Is a negative number , High order 0 Is a positive number int n = -3; System.out.println(Integer.
toBinaryString(n)); /* Regular number : 1)0111 by 4 Maximum value of bit complement , The law is 1 individual 0 and 3 individual 1, Can deduce :
32 Maximum value of bit complement , yes 1 individual 0 and 31 individual 1-----(011111111...) 2)1000 by 4 Minimum value of bit complement , The law is 1 individual 1 and 3 individual 0, Can deduce :
32 Minimum value of bit complement , yes 1 individual 1 and 31 individual 0-----(100000000...) 3)1111 by 4 Bit complement -1, The law is 4 individual 1, Can deduce :
32 Bit complement -1 yes , yes 32 individual 1------------(11111111...) */ int max = 2147483647; //int Maximum value of int
min= -2147483648; //int Minimum value of System.out.println(Integer.toBinaryString(max));
//011111... System.out.println(Integer.toBinaryString(min)); //100000... System.
out.println(Integer.toBinaryString(-1)); //11111...
*
Deep understanding of negative values :

* remember -1 The code is 32 individual 1
* use -1 subtract 0 Weight corresponding to position 11111111111111111111111111111111 = -1
11111111111111111111111111111101 = -1-2 = -3 11111111111111111111111111111001 =
-1-2-4 = -7 11111111111111111111111110010111 = -1-8-32-64 = -105
*
Complementary symmetry :

*
formula :-n=~n+1 conclusion : Complement of a number = This number is reversed +1

*
Examples :
int n = -3; int m = ~n+1; System.out.println(m); //3 -3 The complement is -3 Reverse +1
*
Interview questions :
System.out.println(~100+1); The operation result of the above code is (C) notes : seek 100 Complement of A. -98 B.-99 C.-100 D.-101
System.out.println(~-100+1); The operation result of the above code is (C) notes : seek -100 Complement of A.98 B.99 C.100 D.101
<> Bit operation
~ Reverse & Operation and | Or operation >>> Right shift operation << Left shift operation <>& Operation and
*
Basic rules : have 0 be 0
0 & 0 = 0 0 & 1 = 0 1 & 0 = 0 1 & 1 = 1
*
Align two numbers when calculating , And the corresponding bit
power 8421 6 1 4 f 7 b b b n = 01100001 01001111 01111011 10111011 m = 00000000
00000000 00000000 11111111 0xff k = n&m 00000000 00000000 00000000 10111011
Purpose of the above code :

* take n Last 8 Bit split , Store to k in
* m The number is called a mask ,8 individual 1 be called 8 bitmask
* The above operation is called : Mask operation
code :
int n = 0x614f7bbb; int m = 0xff; // Mask int k = n & m; // take n Last 8 Digit split , Store to k in
System.out.println(Integer.toBinaryString(n)); System.out.println(Integer.
toBinaryString(m)); System.out.println(Integer.toBinaryString(k)); <>| Or operation
* Basic rules : have 1 be 10 | 0 = 0 0 | 1 = 1 1 | 0 = 1 1 | 1 = 1
* Align the two digits during operation , Corresponding bit or operation weight 8421 n = 00000000 00000000 00000000 10111001 0xb9 m
= 00000000 00000000 10111101 00000000 0xbd00 k = n|m 00000000 00000000 10111101
10111001 Significance of the above case : Dislocation merger
code :int n = 0xb9; int m = 0xbd00; int k = n | m; // take n And m Dislocation merger System.out.println(
Integer.toBinaryString(n)); System.out.println(Integer.toBinaryString(m));
System.out.println(Integer.toBinaryString(k)); <>>>> Right shift operation
* Basic rules : take 2 The hexadecimal number moves to the right as a whole , Low level automatic overflow discard , High complement 0 power 8421 6 7 9 f 1 d 9 8 n = 01100111 10011111
00011101 10011000 m = n>>>1 001100111 10011111 00011101 1001100 k = n>>>2
0001100111 10011111 00011101 100110 g = n>>>8 00000000 01100111 10011111
00011101
* code :int n = 0x679f1d98; int m = n>>>1; int k = n>>>2; int g = n>>>8; System.
out.println(Integer.toBinaryString(n)); System.out.println(Integer.
toBinaryString(m)); System.out.println(Integer.toBinaryString(k)); System.out.
println(Integer.toBinaryString(g)); <><< Left shift operation
* Basic rules : take 2 Move hexadecimal numbers to the left as a whole , High overflow discard , Low complement 0 power 8421 5 e 4 e 0 d e e n = 01011110 01001110
00001101 11101110 m = n<<1 1011110 01001110 00001101 111011100 k = n<<2 011110
01001110 00001101 1110111000
* code int n = 0x5e4e0dee; int m = n<<1; int k = n<<2; System.out.println(Integer
.toBinaryString(n)); System.out.println(Integer.toBinaryString(m)); System.out.
println(Integer.toBinaryString(k)); <> Mathematical significance of shift operation power 64 32 16 8 4 2 1 0 1 0 1 = 5
Move left 0 1 0 1 = 10 0 1 0 1 = 20 0 1 0 1 = 40
Left shift code : Self coding verification
int n = 5; System.out.println(n<<1); //10 System.out.println(n<<2); //20 System
.out.println(n<<3); //40
Shift right code : Self coding verification
int n = 100; System.out.println(n>>>1); //? System.out.println(n>>>2); //?
System.out.println(n>>>3); //?
<> Essence note :

<> Pure bottom content , Require as much absorption as possible , Absorb as much as you can , Give up what you can't absorb

*
What is? 2 Base system : Meet 2 enter 1 Counting rules for , Variables in a computer / Constants are based on 2 Binary operation

* 2 Base system :
* rule : Meet 2 enter 1
* number :0 1
* base :2
* power :128 64 32 16 8 4 2 1
* How will 2 Binary conversion to 10 Base system :
* Will one 2 Hexadecimal number each 1 The weights of positions can be added ---------- Positive number
*
What is? 16 Base system : Meet 16 enter 1 Counting rules for

* 16 Base system :
* rule : Meet 16 enter 1
* number :0 1 2 3 4 5 6 7 8 9 a b c d e f
* base :16
* power :4096 256 16 1
* purpose : because 2 Hexadecimal writing is too troublesome , So often use 16 Hexadecimal abbreviation 2 Hexadecimal digit
* How to abbreviate : take 2 Hexadecimal starts from the lowest bit , each 4 position 2 Hexadecimal abbreviation is 1 position 16 Base system
*
Complement :

* Signed number processed in computer ( Positive and negative number ) A coding method of ,java The minimum type of complement in is int,32 digit
* with 4 position 2 Take hexadecimal as an example to explain the coding rules of complement :
* If the calculation exceeds 4 The number of digits will overflow and be discarded automatically , keep 4 The number of digits remains unchanged
* take 4 position 2 Half of a hexadecimal number is used as a negative number
* The highest bit is called the sign bit , High order 1 Is a negative number , High order 0 Is a positive number
* Deep understanding of negative values :
* remember -1 The code is 32 individual 1
* negative : use -1 subtract 0 Weight corresponding to position
* Complementary symmetry :
* conclusion : Complement of a number = This number is reversed +1( Reverse +1) formula : -n=~n+1
6 Complement of =6 Reverse +1
-3 Complement of =-3 Reverse +1
* Interview questions : System.out.println(~100+1); The operation result of the previous code is (C): notes : seek 100 Complement of A.-98 B:-99 C:-100
D:-101 System.out.println(~-100+1); The operation result of the previous code is (C): notes : seek -100 Complement of A.98 B:99 C:100 D:
101
*
Bit operation :

* ~: Reverse (0 change 1,1 change 0)
* &: Operation and ( have 0 be 0)
* |: Or operation ( have 1 be 1)
*
: Right shift operation

* <<: Left shift operation
<> supplement :

* Must master :
* What is? 2 Base system
* What is? 16 Base system ,16 Reasons for the existence of binary
* 2 Binary and 16 Conversion between hexadecimals power : 64 32 16 8 4 2 1 1 1 0 0 1 0 0 = 100 Right shift 1 1 0 0 1 0 = 50 1
1 0 0 1 = 25 1 1 0 0 = 12 power : 64 32 16 8 4 2 1 n 0 1 0 1 = 5 m 0 1 0 1 = 10 k 0 1
0 1 = 20 int n = 5; int m = n<<2; System.out.println(m); //20

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq