-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeWorkNumericalSystems.java
More file actions
64 lines (40 loc) · 1.55 KB
/
HomeWorkNumericalSystems.java
File metadata and controls
64 lines (40 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public class HomeWorkNumericalSystems {
public static void main(String[] args) {
// DECIMAL <=> OCTAL // 1144; 978; 12
int a = 1144;
int a8 = 2170;
System.out.println(2*Math.pow(8,3)+ 1* Math.pow(8,2)+ 7* Math.pow(8,1)+ 0*Math.pow(8,0));
System.out.println(1144/8); // 143
System.out.println(1144%8); // 0
System.out.println(143/8); // 17
System.out.println(143%8); // 7
System.out.println(17/8); // 2
System.out.println(17%8); // 1
System.out.println(2/8); // 0
System.out.println(2%8); // 2
System.out.println(a8);
System.out.println();
int b = 978;
int b8 = 1722;
System.out.println(1*Math.pow(8,3)+ 7*Math.pow(8,2)+ 2*Math.pow(8,1)+2*Math.pow(8,0));
System.out.println(978/8); // 122
System.out.println(978%8); // 2
System.out.println(122/8); // 15
System.out.println(122%8); // 2
System.out.println(15/8); // 1
System.out.println(15%8); // 7
System.out.println(1/8); // 0
System.out.println(1%8); // 1
System.out.println(b8);
System.out.println();
int c = 12;
int c8 = 14;
System.out.println(1*Math.pow(8,1)+4*Math.pow(8,0));
System.out.println(12/8); // 1
System.out.println(12%8); // 4
System.out.println(1/8); // 0
System.out.println(1%8); // 1
System.out.println(c8);
System.out.println();
}
}