-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhole2bin.java
More file actions
42 lines (32 loc) · 807 Bytes
/
whole2bin.java
File metadata and controls
42 lines (32 loc) · 807 Bytes
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
class whole2bin {
static MIPS_OS_Interface mips = new MIPS_OS_Interface();
static void whole2bin(int number) {
int count = 0;
int d = 3;
int n = number;
int rem = 0;
ydob: for(; n != 0 ;){
rem = n%2;
n = n/2;
mips.push(rem);
count = count + 1;
continue ydob;
}
enod: ;
loop: for ( ; count > 0;) {
d = mips.pop();
count = count - 1;
mips.print_d(d);
continue loop;
}
done: ;
mips.print_ci('\n');
}
public static void main(String[] args){
// This method has been written as a driver to test
int arg_0;
arg_0 = Integer.parseInt(args[0]);
whole2bin(arg_0);
return;
}
}