Docsity

Introduzione ai Sistemi Numerici e alla Codifica Binaria, Slide di Elementi di Informatica

Anteprima parziale del testo

Scarica Introduzione ai Sistemi Numerici e alla Codifica Binaria e più Slide in PDF di Elementi di Informatica solo su Docsity!

Data

Numerical data

  • Numerical data is mainly used within scientific context in the modern computers… all the other data types are converted to numerical data to be elaborated
  • Every try for elaborating non numerical data failed or was more inefficient than converting data to numerical data and then elaborate them.

Numeral systems

Non positional:

  • Roman numerals (ex. V, L, D)
  • Arithmetic operations are difficult (ex. V + V = X)

Positional:

  • Arabic (decimal)
  • Mayan (Base 20)

Hybrid

  • Chinese

Positional numbering system in base B

Characteristics:

  • Digits: { 0, 1, 2, ..., B- 1 }
  • Weight of i-th digit: B

i

  • Representation (natural numbers) on N digits i N i i

  a  B

  1 0

A

Binary system

Base = 2 Digits= { 0, 1 } Example: 1012 = 1 × 2 2

  • 0 × 2 1
  • 1 × 2 0 = 1 × 4 + 0 + 1 × 1 = 5 10 111 2
= 1 × 2

2

  • 1 × 2 1
  • 1 × 2 0 = 1 × 4 + 1 × 2 + 1 × 1 = 7 10

Other binary numbers

Terminology

1 0 1 1 0 1 1 0 LSb Least Significant bit MSb Most Significant bit

Some powers of 2

0 = 1 2 11 = 2, 2 1 = 2 2 12 = 4, 2 2 = 4 2 13 = 8, 2 3 = 8 2 14 = 16, 2 4 = 16 2 15 = 32, 2 5 = 32 2 16 = 65, 2 6 = 64 2 17 = 131, 2 7 = 128 2 18 = 262, 2 8 = 256 2 19 = 524, 2 9 = 512 2 20 = 1,048, 2 10 = 1,024 2 30 = 1,073,741,

Binary to decimal conversion

Apply the definition of the weighted sum of the binary numbers: 1101 2 1101 2

= 1 × 2

3

  • 1 × 2 2
  • 0 × 2 1
  • 1 × 2 0 = 8 + 4 + 0 + 1 = 13 10

Decimal to binary conversion

Algorithm for finding the binary representation of a positive integer:

1. Divide by 2 the original value and record the remainder

  1. If the quotient is not zero , continue to divide the new quotient by 2 and record the remainder
  2. Once the quotient equals 0 , the binary value consists of the remainders listed from right to left in the order they were recorded.

13 quotients

remainders

1310 = (^11012)

Limits of the binary system

(natural representation)

bit symbols min

10

max

10 4 16 0 15 8 256 0 255 10 1,024 0 1, 16 65,536 0 65, 32 4,294,967,296 0 4,294,967,

Binary addition

Basic rules : 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 ( carry = 1 )

Binary Subtraction

  • Basic rules: 0 - 0 = 0 0 - 1 = 1 (borrow = 1) 1 - 0 = 1 1 - 1 = 0

Binary Subtraction

The partial subtraction between the bits having the same weight is computed, including the propagation of the borrow: 1 1

  • 0 1 1 0