# Negative Integer Data Representation – Part 1

## Lab: Basics of Digitizing Data

Video Runtime: 10:06

In this episode, you will learn how negative integer numbers are represented in data.

## Study Notes

Think about this for a second. How do you represent a negative number in binary? What makes a positive number different than a negative one?

There’s a problem here…

- All of the bits are taken
- They mean positive numbers
- How do you represent the integers on the other side of zero?

It seems as though adding a sign bit would solve the problem. If the sign is one, then it’s a negative number; otherwise, it’s positive.

Let’s say the left most bit is the sign. Then the remaining bits are the magnitude (or size) of the number.

Is this feasible? What are some of the issues?

One issue is that we lose the one position to the sign within the full range of the scale.

What is the full range of the numbers here? We have from 0 to 128 for the bit positions, which gives us a possible number set of 0 (00000000) to 255 (11111111). And then we have the sign bit too.

Addition is inaccurate. I show an example of adding 7 and -3. It should result in +4, but instead we get 2 and have a carryover that is in the sign’s column.

We also end up two (2) representations of zero, a positive one and a negative. What? How is that possible?

To sum it up, adding a sign bit won’t work because:

- We lose a position
- Addition is inaccurate
- We end up with two representations of zero: +0 and -0

## Why two zeros?

Let’s take a 4-bit system, where the left most bit is the sign. This leaves us with three bits for the magnitude, meaning we can have numbers from 0 to 7. Combining this with the sign bit, we now have a range of -7 to +7.

How many different combinations of numbers can we have? 16. But we’ve only accounted for 15 of those numbers, i.e. 1-7, 0, and -7 to -1. Where is the 16th number? It’s actually a negative representation for zero. Let’s take a look.

For positive numbers, we have 0000 to 0111 to represent 0 to 7. For negative numbers, we have 1000 to 1111 which is -0 to -7. Do you see the two representations for zero?

Can you appreciate how problematic that is? Think about it.

Imagine you are adding numbers together and you have to account for whether it’s positive zero or negative zero. It adds complexity in both hardware and software.

### Why the sign and magnitude approach doesn’t work

In our minds, it seemed like a good idea. But in actuality, the sign is causing us a problem. It is not actually part of the number, but rather just a placeholder. It does not give bearing or weight to being an actual negative number. Instead, it’s just an identification system. It doesn’t have meaning.

Once upon a time, there was a developer... You! This is going to be a good story...

## Episodes

Total Lab Runtime: 02:59:07

- 1 Lab Introductionfree 03:56
- 2 Electronics “on” and “off” Statesfree 12:11
- 3 Symbol to Represent Quantityfree 14:26
- 4 Number System for Statefree 12:44
- 5 Binary – Combining 1s and 0sfree 19:25
- 6 Improving Binary Representationfree 13:45
- 7 The Age of 16 Bit and Hexadecimalfree 15:15
- 8 Binary Additionfree 03:59
- 9 Negative Integer Data Representation - Part 1free 10:06
- 10 Negative Integer Data Representation - Part 2free 18:42
- 11 Real Number Data Representation - Part 1free 17:12
- 12 Real Number Data Representation - Part 2free 10:18
- 13 Textual Data Representationfree 08:47
- 14 Digital Image Data Representationfree 18:21