Before we can get into how these values are stored in memory, we need to talk about numbers, and the different ways we can represent them.
In arguably their most simple form, there are whole numbers (integers), e.g.
5. This type of number has no fractional values.
Then there are fractions, e.g.
1/5. This implies that
1 is being divided into
5 pieces, and is usually represented with the value
0.2. We consider this to be a finite representation, meaning that it stops. If we consider instead
1/3, this is an infinite representation, as we could write
0.3333333333 and so on infinitely in our attempt to represent this fraction.
There’s a distinction which needs to be made here. Our representation of
0.2 is a decimal _number, meaning that it’s written in _base 10. We’ll come back to this.
There’s a further way that we can represent numbers, known as ‘standard form’, or ‘scientific notation’. In standard form we write numbers out in two parts: first, the number itself, with one number ahead of a radix point and the other numbers behind it, and then a value to multiply it by, comprising a base and an exponent, which will return that initial number to its full form.
You’ll likely be familiar with this from very large or small numbers. For example, the earth’s mass can be written as
5.9724 x 10²⁴ kg, which is a handy way of avoiding having to write out
5,972,400,000,000,000,000,000,000 kg in full. Here the
10 is the base, and the exponent is
24, i.e. the number the base is raised to the power of. The numbers multiplied by the base raised to the power of the exponent are known as the significand, or the mantissa, and the amount of these is known as the precision, so in the above example we have a precision of
We can write any number out in this manner, not just extremely large or small ones; if we wanted to represent the number
1 this way we can write it as
1.0 x 10⁰. And we can also represent fractions this way if we use a negative exponent, so if we want to, we can represent
2.0 x 10-¹.
Numbers written in this way are known as ‘floating point numbers’, referring to the moving radix point.