[add] add module java-container and update README. · liquidmavis/java-learning@30a5eac · GitHub
Skip to content

Commit 30a5eac

Browse files
committed
[add] add module java-container and update README.
1 parent 0616b6e commit 30a5eac

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions

java-base/src/main/java/com/brianway/learning/java/base/Binary.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,29 @@
44
* Created by brian on 16/11/10.
55
*
66
* TODO 补码/反码相关知识
7+
* https://www.cnblogs.com/zhangziqiu/archive/2011/03/30/ComputerCode.html
8+
* http://weihe6666.iteye.com/blog/1190033
9+
*
10+
* 在计算机中,负数以原码的补码形式表达。
711
*/
812
public class Binary {
913
public static void main(String[] args) {
1014
int i = 5;
1115
int j = 10;
1216
System.out.println(i + ~j);
17+
18+
int[] arr = new int[] {3, -2};
19+
for (int a : arr) {
20+
//原数
21+
System.out.println("a:" + a + " 二进制:" + Integer.toBinaryString(a));
22+
// 按位取反
23+
System.out.println("~a:" + ~a + " 二进制:" + Integer.toBinaryString(~a));
24+
// 相反数
25+
System.out.println("-a:" + -a + " 二进制:" + Integer.toBinaryString(-a));
26+
27+
System.out.println(-a == ~a + 1);
28+
System.out.println(~a == -a - 1);
29+
}
30+
1331
}
1432
}

java-container/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>java-learning</artifactId>
7+
<groupId>com.brianway.learning.java</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>java-container</artifactId>
13+
14+
</project>

pom.xml

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)