Introduction to Computer Systems
Integer and Floating-Point Representations

# Integer and Floating-Point Representations

## Unsigned Values

These are commonly used to represent bits

## Signed Values

The differences between signed and unsigned is that the most significant bit in signed represents a negative magnitude of zero instead of a positive magnitude.

## Converting To Different Sized Integral Type

- To make values bigger,
*signed*values are preserved by filling the most significant bits with the sign bit from the smaller value - To make a value bigger,
*unsigned*values fill the most significant bits with 0’s - To make a value smaller, the most signifcant bits are lost, regardless of sign

## Converting To Integral Type With Different Signedness

- The cumputer hardware does nothing and the compiler starts generating instructions for the opposite signedness
- By default, when operators with mixed signedness operands are used, the compilier will implicitly convert unsigned values to signed [??]

## Bitwise Tasks To Learn

The following are common activities we need to accomplish that match bitwise operators:

- Set specific bits within a larger integer value -
**OR ( | )** - Clear specific bits within a larger integer value -
**AND ( & )** - Switch specific bits within a larger integer value -
**XOR ( ^ )**

## Scientific Notation

-792 = -7.92 x 10^{2}

- Sign - [-]
- 1 <= Significand < 10 - [7.92]
- Exponent - [2]

## Binary Fractions

- 0.5 = 2
^{-1} - 0.25 = 2
^{-2>} - 0.75 = 0.5 + 0.25 = 2
^{-1}+2^{-2}

## Normalizing Scientific Notation

- For every number, there are multiple equivelant representations
- For consisency, we
**always**choose the normalized representation (1<= significand <= base)

## Negtive Exponents

- How do we represent floating point numbers with negative exponents?
- Add 7 (called a bias) to the exponent before storing to make all of them look positive in binary (no longer need to account for negative values in binary)

## Special Values

- The following are speciall IEEE representations:
- ±∞ (exponents all 1’s, significand all 0’s)
- NaN (exponent all 1’s, significant not all 0’s
- denormalized values (exponent all 0’s)