# Real Number Data Representation – Part 1

## Lab: Basics of Digitizing Data

Video Runtime: 17:12

We need a numbering system and process to represent real numbers, i.e. those floating point and fractional numbers. In this episode, you will learn about this technique.

Your key takeaways from this episode are:

- Computers use scientific notation for floating point
- The size of the machine determines the precision
- The binary pattern is a group of bits for the sign, exponent, and mantissa (or significand)
- Repeating patterns are rounded
- Approximation can occur

## Study Notes

Non-integer numbers come in many formats.

- 5.4920873E+3
- 1000085.3333333
- -12001 * 10-2
- Etc…

What makes up a non-integer? A Fractional.

What do we call these non-integer numbers? Floating point.

With an infinite set of numbers, how do we represent floating point in data? We need a map!

Just like we did with signed integers, we need a map to represent floating point numbers.

What if we…

- identify the sign
- remove the decimal point to convert the number into an integer
- capture the decimal point position

## Mapping System Walkthrough

What are the various elements we need to consider in our new representation map?

- fractional portion
- integer
- decimal point (or radix point)
- sign

But wait. We’re missing something. What else do we need to consider?

Think about all the different combinations of numbers. As we saw with negative integers, the magnitude or size of the number is defined by the range of bits. With floating point numbers, we need to also keep in mind the precision. We’ll talk more about precision shortly. For now, I just want you to store it away in your mind’s database.

To design a new mapping to represent floating point, come with me on a thought experiment.

Let’s say we identify the sign with one bit.

Next, what if we remove the decimal point? This step will convert the number into an integer. For now, let’s just say there are n number of bits in our new mapping system.

Lastly, we need to remember and capture the original position of the decimal point. Right? Let’s say that we have another set of bits to represent this decimal point position.

### Mapping System Walkthrough

Let’s walk through how we might accomplish our new mapping system.

**Step 1**:

Remove the decimal point and remember where its original location was.

Do you remember back in school when you walked the decimal to the left or right? To convert -4875.125 into an integer we need it to be -4875125. Which direction do we walk the decimal point then? I hope you said to the right, since we need it to be a whole number. If we went to the left, then it would be an even smaller number and it would still have that decimal point within the number itself.

Remember to count the positions as you walk it to the right. 1, 2, 3. Therefore, we can say the decimal point has a position equal to three.

**Step 2:**

Next, we need to capture that position and represent it.

Let’s use a capital E to designate that this is the decimal point position. Then you want to note the position, which is 3, and the direction. When moving to the right, this is a negative direction.

Here is our newly mapped number.

Are you wondering about the E and the raised -3 notation? Let’s discuss it.

We want 4875125, but we also want to capture the decimal point position. Correct? What expression would represent the steps we just did? Think about our position system again.

Since we moved the decimal point three places to the right, think about what decimal point number could be multiplied by the new whole number to give us the original floating point number. In other words, -4875.125 = -4875125 x d, where d is the decimal point number. We moved the decimal point three places to the right. Therefore, d equals 0.001.

Now, look at the positional notation in the image above. Notice the 0.001 in orange. What is the base-10 equivalent? 10^{-3}. We can use this value in place of 0.001, as they both represent the same value.

In our new representation, the 10^{-3} is expressed using a capital E^{-3}, where E means exponent.

### What is the mapping?

In a 32-bit machine, floating point is represented by mapping the 32-bits as follows:

- 1 bit (bit 32) is for the sign, where 0 is positive and 1 is negative
- 8 bits (bits 30-23) are for the exponent, which holds the decimal point position.
- 23 bits (bits 22-0) are for the integer.

The integer is called the mantissa or significand.

What about precision, meaning the accuracy of the floating point?

This system is said to be 24-bit precision. Huh? The significand is actually 24 bits when you run the conversion through a formula (which is beyond of the scope of what we are discussing here.) However, the 24^{th} bit is always a 1. Therefore, the computer assumes it to be 1 and it is not stored. In doing so, we only need 23-bits to be stored for the significand.

This mapping is also known as single precision floating point.

### Reference links:

Keep It Simple, Stupid (KISS) - the best kiss you'll get in code.

## 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