在Java里整数的表示就用的是Two's complement
转换方法:一个整数n, 想要得到-n的二进制表示,则可将n的二进制写出来,然后挨个翻转,完成后加1即可。比如 8 -> 00001000 -> 11110111 -> 11111000 -> -8
如此来算,则
00000001 ->1, 00000010 -> 2, ... , 01111111 -> 127
11111111 -> -1, 11111110 -> -2, ... , 10000001 -> -127, 10000000 -> -128
也可以这么想,n和-n加起来就是00000000 (往更高一位进一个1,100000000)
好处:加减都可以换成加法了。12-60 = 12 + (-60)
数学上怎么理解:
-n就是0 - n,然后0我们可以想像成100000000, 11111111-n就是把n 挨个翻转,但是11111111还比“0“多减了个1,所以我们要把结果加1. (就是减法上借位的思想)。
Friday, January 18, 2019
01-18-2019
刷题:
Leetcode 819,
很简单,需要补充的:String methods, Collections (Map, Set), Map.Entry methods. Regex
Core Java Chapter 2 finished
Leetcode 819,
很简单,需要补充的:String methods, Collections (Map, Set), Map.Entry methods. Regex
Core Java Chapter 2 finished
Tuesday, January 15, 2019
Friday, January 11, 2019
Wednesday, January 9, 2019
01-09-2019
农历生日
路上看microservices
看Core Java I 11th edition
Read about 11 buzzwords (Chapter 1.2)
Chapter 1
1.2 11 buzzwords
路上看microservices
看Core Java I 11th edition
Read about 11 buzzwords (Chapter 1.2)
Chapter 1
1.2 11 buzzwords
- Simple
- Object-Oriented
- Distributed
- Robust
- Secure
- Arcitecture-Neutral (JVM, Java runtime system)
- Portable (size of primitive dat types are specified, for example int is always 32bit.)
- Interpreted (jshell in Java 9 for rapid and exploratory programming)
- High-Performance (just-in-time compilers)
- Multithreaded (use more processors in parallel)
- Dynamic
1.3 Java applets and the Internet
applets: Java programs that work on web pages (need a supporting browser)
But actually Flash became popular.
Nowadays usually can use HTML and Javascript
Subscribe to:
Posts (Atom)