1. What is a Floating-Point Number?
Imagine you have a long number like 123.456. Sometimes, numbers are very big like 1000000.0, or very small like 0.000001. A floating-point number is a way for the computer to store these numbers, no matter how big or small they are.
2. Parts of a Floating-Point Number
A floating-point number is stored in three parts:
- Sign (S): Tells if the number is positive or negative. (1 bit)
- Exponent (E): Tells where the decimal point is. (A few bits)
- Mantissa (M): Tells the actual digits of the number. (A lot of bits)
Think of it like a scientific notation:

3. What Does This Mean?
- Sign (S): If
S
is 0, the number is positive. If S
is 1, the number is negative.
- Mantissa (M): The actual digits, but usually between 1 and 2.
- Exponent (E): Tells us how to move the decimal point.
4. Example: Storing 5.75
Let’s see how to store the number 5.75:
- Step 1: Write in binary:
- 5.75 in binary is
101.11
.
- This is
1.0111 × 2^2
.
- Step 2: Break it down:
- Sign (S):
0
(because it’s positive).
- Mantissa (M):
0111
(we drop the leading 1.
).
- Exponent (E): The exponent is
2
.
- Step 3: Adjust the Exponent:
- We need to add a bias to store the exponent. For simplicity, let’s say the bias is 127 (common for 32-bit float).
- New Exponent
E
= 2 + 127 = 129
.
- Step 4: Put It Together:
- Sign (S):
0
- Exponent (E):
129
in binary is 10000001
.
- Mantissa (M):
01110000000000000000000
.
- Memory Representation:
-
The number 5.75 in memory is stored as:
0 | 10000001 | 01110000000000000000000
-
This is a 32-bit floating-point number.