Base Conversion Guide: Decimal to Binary, Octal, Hexadecimal and Vice Versa, Summaries of Number Theory

A step-by-step guide on how to convert numbers from decimal to binary, octal, and hexadecimal bases, as well as the reverse process. It includes examples and formulas for integer and fractional parts.

Typology: Summaries

2021/2022

Uploaded on 09/27/2022

rakshan
rakshan 🇺🇸

4.6

(18)

239 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Base Conversion Guide
UCR ·Math 135A
Decimal Binary Octal Hexidecimal
(Base 10) (Base 2) (Base 8) (Base 16)
0 0000 00 00
1 0001 01 01
2 0010 02 02
3 0011 03 03
4 0100 04 04
5 0101 05 05
6 0110 06 06
7 0111 07 07
8 1000 10 08
9 1001 11 09
10 1010 12 0A
11 1011 13 0B
12 1100 14 0C
13 1101 15 0D
14 1110 16 0E
15 1111 17 0F
1. Convert from base βto base 10.
Integer Part:
(anan1· · · a1a0)β=anβn+an1βn1+... +a1β1+a0β0
= (x)10
Fraction Part:
(0.b1b2b3· · · )β=b1β1+b2β2+b3β3+...
= (x)10
Example: Convert 21.112 in base 3 to base 10
(21.112)3= 2 31+ 1 30+ 1 31+ 1 32+ 2 33
= 2 3+11+1.333 + 1 .111 + 2 .037
=6+1+.333 + .111 + .074
= (7.518...)10
(1)
1
pf3
pf4
pf5

Partial preview of the text

Download Base Conversion Guide: Decimal to Binary, Octal, Hexadecimal and Vice Versa and more Summaries Number Theory in PDF only on Docsity!

Base Conversion Guide

UCR · Math 135A

Decimal Binary Octal Hexidecimal (Base 10) (Base 2) (Base 8) (Base 16) 0 0000 00 00 1 0001 01 01 2 0010 02 02 3 0011 03 03 4 0100 04 04 5 0101 05 05 6 0110 06 06 7 0111 07 07 8 1000 10 08 9 1001 11 09 10 1010 12 0A 11 1011 13 0B 12 1100 14 0C 13 1101 15 0D 14 1110 16 0E 15 1111 17 0F

  1. Convert from base β to base 10. Integer Part:

(anan− 1 · · · a 1 a 0 )β = an ∗ βn^ + an− 1 ∗ βn−^1 + ... + a 1 ∗ β^1 + a 0 ∗ β^0 = (x) 10

Fraction Part:

(0.b 1 b 2 b 3 · · · )β = b 1 ∗ β−^1 + b 2 ∗ β−^2 + b 3 ∗ β−^3 + ... = (x) 10

Example: Convert 21.112 in base 3 to base 10

(21.112) 3 = 2 ∗ 31 + 1 ∗ 30 + 1 ∗ 3 −^1 + 1 ∗ 3 −^2 + 2 ∗ 3 −^3 = 2 ∗ 3 + 1 ∗ 1 + 1 ∗ .333 + 1 ∗ .111 + 2 ∗. 037 = 6 + 1 + .333 + .111 +. 074 = (7. 518 ...) 10

  1. Convert from base 10 to base β. Integer Part:

(a) Divide the number by β and record the remainder. (b) Divide the resulting quotient by β and record the remainder. (c) Repeat (d) The number in base β is the remainders written in backwards order.

Fraction Part:

(a) Multiply the number by β and record the integer. (b) Multiply the resulting number (ignoring the integer) by β and record the integer. (c) Repeat (d) The number in base β is the integers written in forwards order.

Example: Convert 15.4375 in decimal (base 10) to binary (base 2)

  • First convert the integer part: 15 ÷ 2 = 7 R 1 7 ÷ 2 = 3 R 1 3 ÷ 2 = 1 R 1 1 ÷ 2 = 0 R 1 Hence (15) 10 = (1111) 2.
  • Second convert the fraction part:
  1. 4375 ∗ 2 = 0. 8750

  2. 875 ∗ 2 = 1. 750

  3. 75 ∗ 2 = 1. 50

  4. 5 ∗ 2 = 1. 0 Hence (0.4375) 10 = (0.0111) 2

  • Final Answer: (15.4375) 10 = (1111.0111) 2
  1. Convert from base α to base β.
  • First convert from base α to base 10.
  • Second convert from base 10 to base β.
  • This implies (52.234375) 10 = (110100.001111) 2 = (1.10100001111) 2 × 25
  • The mantissa with added zeros is then 10100001111000000000000. (c) Identify the exponent:
  • First we solve for c: c − 127 = 5 implies c = (132) 10
  • Second we convert 132 from base 10 to binary.

132 ÷ 8 = 16 R 4

16 ÷ 8 = 2 R 0 2 ÷ 8 = 0 R 2 So (132) 10 = (204) 8 = (010 000 100) 2 = (10 000 100) 2

  • The exponent is 10000100.

(d) Put it all together: First list the number from step (a), then step (c), then step (b):

(11000010010100001111000000000000) 2

(e) Convert to hexidecimal:

  • First split into numbers of length 4:

(1100 0010 0101 0000 1111 0000 0000 0000) 2

  • Second convert each 4 digit number to hexidecimal to get the answer:

(C 250 F 000) 16

  1. Convert from single precision machine representation to decimal. Steps:

(a) Convert the machine representation in hexidecimal to binary. (b) Identify the sign, exponent, mantissa

  • sign: first digit
  • exponent: next 8 digits
  • mantissa: last 23 digits (can ignore trailing zeros) (c) Convert the sign
  • 0 represents +
  • 1 represents - (d) Convert the exponent
  • Convert the exponent number from binary to decimal, call the number in base 10 c.
  • Calculate c − 127, call this number n. (e) Convert the mantissa
  • Suppose your mantissa is b 1 b 2 · · · bm, then write

± 1 .b 1 b 2 · · · bm × 2 n

where the sign is determined by step (c).

  • Convert this number to standard form (i.e. not scientific notation).
  • Convert this number to base 8, then to base 10, i.e. decimal. This is your final answer.

Example: Convert the single precision machine representation (BA390000) 16 to decimal.

(a) Convert the machine representation to binary:

(BA390000) 16 = (1011 1010 0011 1001 0000 0000 0000 0000) 2

(b) Identify the sign, exponent, mantissa:

  • sign: 1
  • exponent: 01110100
  • mantissa (without trailing zeros): 0111001 (c) Convert the sign: 1 represents - (negative) (d) Convert the exponent:
  • Convert from base 2 to base 10 (01 110 100) 2 = (164) 8 = 1 ∗ 82 + 6 ∗ 81 + 4 ∗ 80 = 64 + 48 + 4 = (116) 10