fds

Representation

  • A bit is the most basic unit of information
  • It can have two possible states: on (1) or off (0)
  • Usually grouped into bigger data structures (bytes)

In mathematics we call a bigger data structures as a tuple

  • ordered structure of elements, each element being a digit

In digital systems, we have ordered tuples to represent numbers

Non-negative integers

  • Digit-vector (or string) representing the integer is denoted by
  • The least significant digit (or low-order digit):
  • The most significant digit (or high-order digit):

(Non) Redundant Number Systems

A number system is nonredundant if

  • each digit-vector represents a different integer A number system is redundant if
  • The are numbers represented in multiple ways

Weighted Number Systems

We have the digits associated to a weight corresponding to its position in the number:

When those weights are of the form Which is a radix number system

Fixed and Mixed Radix Number Systems

All the elements of the radix vectors have the same value (the radix) a fixed-radix number

Fixed RadixMixed Radix
DecimalTime ()
BinaryImperial units
OctalBits Bytes kb
Hex

Conventional Number Systems

A system with

  • a fixed positive radix
  • a canonical set of digit values
    • A radix- conventional number system

Binary/Octal/Hex to/from Decimal

We can convert binary to decimal

For decimal to binary, you divide by the base, the remainder is the bit value

Signed Integers

The most significant bit defines whether the number is postive or negative

PostiveNegative
01

We can have symmetrical number system, where the positive and negative are only differentiated by the sign

Left Arithmetic Shift

We discard the second most significant bit (to keep the sign), and shift the rest

Right Arithmetic Shift

We shift to the right (keeping the sign in the same spot), padding with 0s

True and Complement (TC)

A signed integer is represented by a positive integer

For , we have

Range Extension

If we want to represent a signed number on more bits than it currently has, we move the sign to the first and pad the rest with zeros/ones (if negative)

Example

() to 8 bits We move the sign, and pad with ones (negative)

Left Arithmetic Shift

We discard the second most significant bit and shift the rest to the left (pad the end with zeros)

Right Arithmetic Shift

We shift to the right, copying the sign to the new most significant bit, we lost the least significant bit

Different Codes

Hamming weight and distance

Distance: How much the numbers differ from each other, bitwise (so the number of different bits)

Weight: The amount of ones () in a number

Gray’s code

When you increment the number, the hamming distance is 1