Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Friday, July 28, 2023

Number System Conversions

This blog post covers various number system conversions, explaining how to convert numbers between decimal, octal, hexadecimal, and binary representations. The content presents step-by-step procedures for each conversion, making it easy for readers to follow along.

1) Decimal to Octal:

231

231 ÷ 8 = 28

231 % 8 = 7

28 ÷ 8 = 3

28 % 8 = 4

3 ÷ 8 = 0

3 % 8 = 3

So, the octal equivalent of the decimal number 231 is 347.

Octal to Decimal
347

3 * 8^2 + 4 * 8^1 + 7 * 8^0
3 * 64 + 4 * 8 + 7 * 1
192 + 32 + 7 = 231

So, the decimal equivalent of the octal number 347 is 231.

2) Decimal to Hexadecimal
200

200 ÷ 16 = 12
200 % 16 = 8

12 ÷ 16 = 0
12 % 16 = 12 (C)
So, the hexadecimal equivalent of the decimal number 200 is C8.

Hexadecimal to Decimal
C8

C * 16^1 + 8 * 16^0

12 * 16 + 8 * 1
192 + 8 = 200
So, the decimal equivalent of hexadecimal number C8 is 200.

3) Decimal to Binary
125

125 ÷ 2 = 62
125 % 2 = 1

62 ÷ 2 = 31
62 % 2 = 0

31 ÷ 2 = 15
31 % 2 = 1

15 ÷ 2 = 7
15 % 2 = 1

7 ÷ 2 = 3
7 % 2 = 1

3 ÷ 2 = 1
3 % 2 = 1

1 ÷ 2 = 0
1 % 2 = 1
So, the binary equivalent of the decimal number 125 is 1111101.

Binary to Decimal
1111101

= (1 * 2^6) + (1 * 2^5) + (1 * 2^4) + (1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2^0)
= 64 + 32 + 16 + 8 + 4 + 0 + 1
= 125

So, the decimal equivalent of the binary number 1111101 is 125.