Decimal to Binary, Octal, Hexadecimal, and Other Base n numbers

Suhail Roushan πŸš€
2 min readSep 8, 2021

--

Decimal to Binary, Octal, Hexadecimal, and Other Base n numbers

1.1 Decimal to Binary

(45)₁₀ to ( )β‚‚

1st Method LCM

45/2 Quotient = 22 , Remainder = 1

22/2 Quotient = 11, Remainder = 0

11/2 Quotient = 5 , Remainder = 1

5/2 Quotient = 2, Remainder = 1

2/2 Quotient = 1, Remainder = 0

Take From Last Quotient to Upper Last Remainder

1 0 1 1 0 1

(45)₁₀ = (101101)β‚‚

1.2 Decimal to Octal

(45)₁₀ to ( )β‚ˆ

2 Methods

  1. Decimal to Octal
  2. Decimal to Binary β€” Binary to Octal

Decimal to Octal

(45)₁₀ to ( )β‚ˆ

1st Method LCM

45/8 Quotient = 5, Remainder = 5

5/8 Quotient = 5 , Remainder = 0

5 5

(45)₁₀ to (55 )β‚ˆ

2nd Method

Decimal to Binary β€” Binary to Octal

(46)₁₀ to ( )β‚‚

46/2 Quotient = 23 , Remainder = 0

23/2 Quotient = 11, Remainder = 1

11/2 Quotient = 5 , Remainder = 1

5/2 Quotient = 2, Remainder = 1

2/2 Quotient = 1, Remainder = 0

1 0 1 1 1 0

(46)₁₀ = (101110)β‚‚

Binary to Octal

1 0 1 1 1 0

Divide the Number in 2 Parts

101 and 110

1 0 1

²²x1+²¹x0+²⁰x1

4x1+ 2x0 + 1x1

4+1 = 5 (1st Digit) β€” β€” β€” β€” β€” β€” 1

110

²²x1 + ²¹x1 + ²⁰x0

4x1 + 2x1+1x0

4+2 = 6 (2nd Digit) β€” β€” β€” β€” β€” β€” 2

= 56

(101110)β‚‚ = (56)β‚ˆ

1.3 Decimal to Hexadecimal

(47)₁₀ to ( )₁₆

2 Methods

  1. Decimal to Hexadecimal
  2. Decimal to Binary β€” Binary to Hexadecimal

1st Method LCM

(47)₁₀ to ( )₁₆

47/16 Quotient = 32, Remainder = 15

32/16 Quotient = 2, Remainder = 0

Where in Hexadecimal F = 15

So There is 2 and F

(47)₁₀ to (2F )₁₆

2nd Method Decimal to Binary β€” Binary to Hexadecimal

(47)₁₀ to ( )β‚‚

47/2 Quotient = 23 , Remainder = 1

23/2 Quotient = 11, Remainder = 1

11/2 Quotient = 5 , Remainder = 1

5/2 Quotient = 2, Remainder = 1

2/2 Quotient = 1, Remainder = 0

1 0 1 1 1 1

(47)₁₀ to (101111 )β‚‚

Binary to Hexadecimal

1 0 1 1 1 1

Where 1 0 in binary is 2

and 1111 is F

(101111 )β‚‚ = (2F )₁₆

1.4 Decimal to N Base Number

(47)₁₀ to ( )₆

1st Method LCM

47/6 Quotient = 7, Remainder = 5

7/6 Quotient = 1 , Remainder = 1

(47)₁₀= (115)₆

--

--

Suhail Roushan πŸš€

⭐ Software Engineer at T-Works πŸ§‘β€πŸ’» Full Stack Web Developer πŸŽ“ CS.CODE.IN Fellow '21 πŸ’‘ Startup Tech Innovator πŸ‘¨β€πŸŽ¨ UI/UX Designer πŸ€– Automation