Friday, January 18, 2019

怎么理解Two's complement

在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. (就是减法上借位的思想)。


01-18-2019

刷题:
Leetcode 819,
很简单,需要补充的:String methods, Collections (Map, Set), Map.Entry methods. Regex

Core Java Chapter 2 finished


Friday, January 11, 2019

01-10-2019

Udemy Web Developer Bootcamp Section4 finished.
form, input, label etc.



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

  1. Simple
  2. Object-Oriented
  3. Distributed
  4. Robust
  5. Secure
  6. Arcitecture-Neutral (JVM, Java runtime system)
  7. Portable (size of primitive dat types are specified, for example int is always 32bit.)
  8. Interpreted (jshell in Java 9 for rapid and exploratory programming)
  9. High-Performance (just-in-time compilers)
  10. Multithreaded (use more processors in parallel)
  11. 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

打表学习从2019.1.10开始

用小本本记下来每天做了什么,学到了什么。