Pick a random decimal number between 100 and 999 and convert it to binary, octal, and hexadecimal while showing work. That's it!
random number 397
binary:
110001101
octal:
615
hexadecimal
18D
private static String convert(int n, int b) { StringBuilder sb = new StringBuilder( ); int mask = 0; for (int i = 0; i < b; i++) { mask |= 1 << i; } while (n > 0) { int digit = n & mask; n = n>>b; if (digit < 10) { sb.insert( 0, digit ); }else { char c = (char)('A' + (digit-10)); sb.insert( 0, c ); } } return sb.toString(); }
Name: Jasmine (I think I figured it out?)
Number: 123
----------------------------------------------------
Binary:
123/2=61 R 1
61/2=30 R 1
30/2=15 R 0
15/2=7 R 1
7/2=3 R 1
3/2=1 R 1
1/2=0 R 1
Number = 1111011
----------------------------------------------------
Octal:
123/8=15 R 3
15/8=1 R 7
1/8 =0 R 1
Number = 173
----------------------------------------------------
Hexadecimal:
123/16= 7 R 11
7/16 =0 R 7
Number = 711
Name: Andy number: 100 _______________
binary
100/2=50 R0
50/2=25 R0
25/2=12 R1
12/2=6 R0
6/2=3 R0
3/2=1 R1
1/2=0 R1 number: 1100100 _______________
octal
100/8=12 R4
12/8=1 R4 1/8=0 R1
number: 144 ________________
hexadecimal
100/16=6 R4 6/16=0 R6
number: 64
Binary
160/2=80 R0
80/2=40 R0
40/2=20 R0
20/2=10 R0
10/2=5 R0
5/2=2 R1
2/2=1 R0
0100000
Octal
160/8=20 R0
20/8=2 R4
2/8=0 R2
240
Hexadecimal
160/16=10 R0
10/16=1 R10
100
150
150/2=75R0
75/2=37R1
37/2=18R1
18/2=9R0
9/2=4R1
4/2=2R0
2/2=1R0
10010110
________
150
150/8=18R6
18/8=2R2
226
_________
150
150/16=9R6
96
number 100 converted to binary
100/2=50 R=0(R=remainder), 50/2=25 R=0 ,25/2=12 R=1, 12/2=6 R=0, 6/2=3 R=0, 3/2= 1 R=1, 1/2=0 R=1. Binary is 1100100
number 100 converted to octal
100/8=13 R=2, 13/8=1 R=5, 1/8=0 R=1
octal is 152
number 100 converted to hexadecimal
100/16=6 R=4, 6/16=0 R=1
hexadecimal is 14
my number 200
200/2= 100 r 0
100/2= 50 r 0
50/2= 25 r0
25/2= 12 r 1
12/2= 6 r 0
6/2= 3 r 0
3/2= 1 r 1
1/2= 0 r 1
11001000
200/8= 25 r 0
25/8= 3 r 1
3/8=0 r 5
510
200/16 r 8
16/16= 1 r0
08
So My Number = 888
R=Remainder BTW
Binary:
888/2=444R0
444/2=222R0
222/2=111R0
111/2=55R1
55/2=27R1
27/2=13R1
13/2=6R1
6/2=3R0
3/2=1R1
1/2=0R1
<<<<<<<1101111000>>>>>>>
Octal:
888/8=111R0
111/8=13R7
13/8=1R5
1/8=0R1
<<<<<<<1570>>>>>>>
Hexadecimal:
888/16=55R8
55/16=3R7
3/16=0R3
<<<<<<<378>>>>>>
Number: 110
110/2=55 R: 0, 55/2=27 R:1, 27/2=13 R:1, 13/2=6 R: 1, 6/2=3 R:0, 3/2= 1 R:1, 1/2=0 R:1
Binary: 1101110
110/8=13 R: 6, 13/8=1 R: 5, 1/8=0 R:1
Octal: 156
110/16=6 R: E, 6/16=0 R: 6
Hexadecimal: 6E
My number: 150
R = remainder
Binary:
150/2 = 75 R0
75/2 = 37 R1
37/2 = 18 R1
18/2 = 9 R0
9/2 = 4 R1
4/2 = 2 R0
2/2 = 1 R0
1/2 = 0 R1
Answer: 10010110
Octal:
150/8 = 18 R6
18/8 = 2 R2
2/8 = 0 R2
Answer: 224
Hexadecimal:
150/16 = 9 R6
9/16 = 0 R9
Answer: 96
student name: philip
number: 100
binary
100/2=50 R0
50/2=25 R0
25/2=12 R1
12/2=6 R0
6/2=3 R0
3/2=1 R1
number: 0.1001
octal
100/8=96 R4
96/8=12 R0
12/8=1 R4
number: 0.404
hexadecimal
100/16=6 R4
number: 0.4
Number: 300
Binary: 100101100
300/2 = 150 R0
150/2 = 75 R0
75/2 = 37.5 = 37 R1
37/2 = 18.5 = 18 R1
18/2 = 9 R0
9/2 = 4.5 = 4 R1
4/2 = 2 R0
2/2 = 1 R0
1/2 = 0.5 = 0 R1
Octal: 454
300/8 = 37.5 = 37 R4
37/8 = 4.625 = 4 R5
4/8 = 0.5 = 0 R4
Hexadecimal: 12C
300/16 = 18.75 = 18 R12
18/16 = 1.125 = 1 R2
1/16 = 0.0625 = 0 R1
Student name : Jasmine
I have no clue how to do this because I missed the class.
Number:220
Binary
220/2=110R0
110/2=55R0
55/2=27R1
27/2=13R1
13/2=7R1
7/2=3R1
3/2=1R1
1/2=0R1
Binary:11111100
Octal
220/8=27R4
27/8=3R3
3/8=0R3
octal:334
Hexadecimal
220/16=13R12=C
13/16=0R13=D
hexadecimal:DC
My Number: 420
BINARY: 110100100
420 ÷ 2 = 210 R 0
210 ÷ 2 = 105 R 0
105 ÷ 2 = 52 R 1
52 ÷ 2 = 26 R 0
26 ÷ 2 = 13 R 0
13 ÷ 2 = 6 R 1
6 ÷ 2 = 3 R 0
3 ÷ 2 = 1 R 1
1 ÷ 2 = 0 R 1
OCTAL: 644
420 ÷ 8 = 52 R 4
52 ÷ 8 = 6 R 4
6 ÷ 8 = 0 R 6
HEXADECIMAL: 1A4
420 ÷ 16 = 26 R 4
26 ÷ 16 = 1 R 10 (A)
1 ÷ 16 = 0 R 1
Name: Sammie Zhang
My number: 112
Binary:
112/2 = 56 R = 0
56/2 = 28 R = 0
28/2 = 14 R = 0
14/2 = 7 R = 0
7/2 = 3 R = 1
3/2 = 1 R = 1
1/2 = 0 R = 1
Answer: 1110000
Octal:
112/8 = 14 R = 0
14/8 = 1 R = 6
1/8 = 0 R = 1
Answer: 160
Hexadecimal:
112/16 = 7 R = 0
7/16 = 0 R = 7
Answer: 70
Name: Kimi
My Number: 100
R = reminder
Binary:
100/2 = 50 R = 0
50/2 = 25 R = 0
25/2 = 12 R = 1
12/2 = 6 R = 0
6/2 = 3 R = 0
3/2 = 1 R = 1
1/2 = 0 R = 1
ANS: 1100100
Octal:
100/8 = 12 R = 4
12/8 = 1 R = 4
1/8 = 0 R = 1
ANS: 144
Hexadecimal:
100/16 = 6 R = 4
6/16 = 0 R = 6
ANS: 64
My number: 200
Binary:
200/2=100, R=0
100/2=50, R=0
50/2=25, R=0
25/2=12, R=1
12/2=6, R=0
6/2=3, R=0
3/2=1, R=1
1/2=0, R=1
Answer: 11001000
Octal:
200/8=25, R=0
25/8=3, R=1
3/8=0, R=3
Answer: 310
Hexadecimal:
200/16=12, R=8
12/16=0, R=12 (C)
Answer: C8
My work: Number=400
Re=Remainder
Binary:
400/2=200, Re=0
200/2=100, Re=0
100/2=50, Re=0
50/2=25, Re=0
25/2=12, Re=(0.5)
Octal:
400/8=50, Re=0
50/8=6, Re=(0.25)
6.25/8=0, Re=(0.78125)
0.78125/8=0, Re=(0.09765625)
0.09765625/8=0, Re=(0.01220703125)
Hexadecimal:
400/16=25, Re=0
25/16=1, Re=(1.5625)
1.5625/16=1, Re=(0.09765625)
0.09765625/16=0, Re=(0.00610351562)