Why doesn't .3 - .2 - .1 = 0
1 view (last 30 days)
Show older comments
I was bored yesterday at work and I was playing around with some decimal numbers when I stumbled across something I thought was pretty interesting.
.3 - .2 - .1 != 0
but
.2 - .1 - .1 = 0
then I began to run some other tests and I found out that only .3 and .8 are the only numbers that you use that'll not get you a 0 answer. If you take:
.4 - .2 - .1 - .1 = 0
and
.9 -.2 -.1 -.1 -.1 -.2 -.1 -.1 = 0
If you change any of the .2's to two - .1's you don't get 0. So what’s so special about those 2 decimals that make them the only ones that don't work with basic subtraction?
0 Comments
Accepted Answer
More Answers (1)
Thomas
on 9 Nov 2012
Edited: Thomas
on 9 Nov 2012
This should answer your question. Look at the wiki under the section Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero? (might have to scroll on the page to locate...)
2 Comments
Oleg Komarov
on 9 Nov 2012
@Lucas, if you already know that you wouldn't be asking the question in the first place. I recommend to read the FAQ more carefully.
See Also
Categories
Find more on Characters and Strings 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!