1. Member
Join Date
Apr 2011
Posts
5
Rep Power
0

## Double subtraction

In subtracting one double from another, namely 45.32 - 45.31, I get a result of 0.00999999999999801. According to all the math I've ever learned, the answer should be .01.

I asked my professor about this, and his response was that "45.31 may be a repeating decimal." To which I responded, "I have no idea what that means."

2. Member
Join Date
Apr 2011
Posts
5
Rep Power
0
Thanks, but I'm in intro the programming and could use a little simpler explanation.

3. 2 / 3

Write the answer to that EXACTLY in decimal.

4. Member
Join Date
Apr 2011
Posts
5
Rep Power
0
OK, I'm not trying to be difficult here, but I still don't get it!

5. the answer is 0.666666666666666666666666666666666666666666666666 66666666666666666666666666666666666666666666666666 66666666666666666666666666666666666666666666666666 6666666666666666666666666666666666666666666

You cannot represent that value accurately in decimal. Guess what happens to some values in binary?

6. Member
Join Date
Apr 2011
Posts
5
Rep Power
0
I understand that analogy. But 4.11 - 4.10 is .01. The damn calculator says it's so. Can you explain it to me like I'm a complete idiot, which I'm not, but I am just not following you.

7. The damn calculator cheats. Since not all decimal values can be represented exactly in binary some inaccuracy creeps in. It is a known artifact of floating point arithmetic. All of which is explained in the article linked above if you had bothered to read it. If you did read it and didn't understand then read it again and again and again until you do understand because quite frankly anything I say here is just repeating what that article says. So why should I waste my time?

8. Member
Join Date
Apr 2011
Posts
5
Rep Power
0
Wow. You are an asshole. I am a new programmer seeking an answer that I can understand. Would anyone else like to help?

9. Good luck with getting anyone else to explain it.

You have been provided a link
I have given you an explanation
You used offensive language against me which violates the conditions you agreed to when joining this forum.

I doubt very much anyone will waste their time helping an ungrateful idiot like you!

10. Short answer: Since all numbers are represented in binary, some rounding errors occur when you use floating point arithmetic.

11. Senior Member
Join Date
Jan 2011
Location
Rizal Province, Philippiines
Posts
167
Rep Power
0
Your noob programmer cause you easily get angry, many problems still comes along the way if your going to continue to be as programmer.

12. Originally Posted by bmbishop
Wow. You are an asshole. I am a new programmer seeking an answer that I can understand. Would anyone else like to help?
Abuse reported.

db

13. *sigh*
Come on people, let's help him out here. He's still new and probably doesn't even know what binary means or how it works. Why turn him off to programming now?

@bmbishop
As you probably know, computers use a binary system (1's and 0's) to store data, such as values and instructions. Humans use a decimal system. So like 2/3 in decimal is an irrational number, 45.31 is an irrational number in binary, aka, there is no exact representation of 45.31 as 1's and 0's.

Hope that helps :)

(but really, please do not use offensive language, even if you are angry)

14. Don't waste your time. OP has moved on to pollute another forum.

15. Well he did get mad that you were treating him as if he understood this.

16. No I treated him as a lazy person who expected us to spoonfeed him the answer instead of reading the article. I also didn't apreciate his attitude that because he didn't understand then somehow that was my fault. If I attended a lecture on Quantum Mechanics by Stephen Hawking it would all go over my head. That is my fault not Stephen's.

17. But most likely he didn't understand the article because of some potentially confusing words.
Thanks, but I'm in intro the programming and could use a little simpler explanation.

18. I did provide a simpler explanation and the idiot still not understand nor appreciate it.

I'm also done arguing with you!

19. Grrrrrr...

I just felt a little pity for the guy, as he is a n00b, ignoring the offensive language part.
Last edited by ra4king; 04-21-2011 at 04:56 AM.

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•