Section 6.2 Digital Representation of Floats
So far we have learned how integers (positive and negative) are stored in the computerβs memory. How about decimal numbers, also known as floats?
In this next video youβll find out how floats are stored in memory!
Aside: Video Description.
How are real numbers (floats) represented/stored in the computer?
Write in scientific notation (decimal):
\begin{equation*}
-5.0324235\times 10^3
\end{equation*}
where
- is the sign,
5.0324235 is the "mantissa", and
3 is the exponent.
In binary, this representation takes on the following form:
\begin{equation*}
-1.mantissa\times 2^{exp}
\end{equation*}
where
number =
sign*
1.mantissa*
2^exponent
Float: range of numbers varies, but ANSI minimum is
\(10^{-37}\) to
\(10^{37}\)
Note: can declare long double ---
not necessarily different from double
Check Your Understanding Check Your Understanding
1.
The binary representation of the decimal number 0.75 is 0.11 (which basically stands for \(2^{-1} + 2^{-2} = \frac{1}{2} + \frac{1}{4} = 0.75\)). In scientific notation, this binary number would be written as:
\begin{equation*}
1.1 * 2^{-1}
\end{equation*}
Suppose now that 0.75 is stored (in the binary representation) as a float. In this representation, choose the correct option for the following components of the float: