/Users/lyon/j4p/src/bookExamples/appJBitOps/Base16.java
|
1 /**
2 * Created by IntelliJ IDEA.
3 * User: dlyon
4 * Date: Jan 26, 2004
5 * Time: 4:17:11 PM
6 * To change this template use Options | File Templates.
7 */
8 package bookExamples.appJBitOps;
9
10 public class Base16 {
11 // hex numbers us 0x to start
12 // 0xffdead
13 // octal numbers use 0 to start
14 // 0777771234
15 public static void main(String args[]) {
16 int i = 1;
17 System.out.println("~1=" +
18 Integer.toString(~i));
19 System.out.println("~1+1=" +
20 Integer.toString(~i + 1));
21 int k = ~i + 1;
22 System.out.println("k=" + k);
23 System.out.println(0x28);
24 String s = Integer.toString(40, 16);
25 System.out.println("in base 16:" + s);
26 System.out.println("in base 2:" +
27 Integer.toString(40, 2));
28 System.out.println("in base 8:" +
29 0177);
30 int q = 0765;
31
32 }
33
34 }
35