Can the double-precision floating point number 0.72 be represented exactly in Matlab? Explain.
Show older comments
Can the double-precision floating point number 0.72 be represented exactly in Matlab? Explain. This is one of my practice problems for the test and the answer does not make sense to me.
This was his answer
No, because its mantissa has non-zero bits beyond the 52 bits allowed. It has the following repeating pattern for the significand: 10111000010100011110.
Answers (1)
Roger Stafford
on 5 Mar 2017
Edited: Roger Stafford
on 5 Mar 2017
In almost all computers, floating point numbers are represented in binary format. This means that the only numbers that can be represented exactly are the rational numbers in which the reduced form denominator is some power of two, such as 35/128. The number .72 in reduced fraction form would be 18/25, which is clearly not of the required form. It is analogous to trying to represent 1/3 exactly in a decimal calculator - it can’t be done because in decimal the number looks like this:
1/3 = .33333333333333 .... infinitely far out
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!