I'm developing an application at the moment, which uses some stochastic matrices. And I've hit something of a problem. The rows of the matrix must all add up to one, and they do, however when I sum the values in the row together I get 1.0000000000000002 as the result! How has this happened?
I'm fairly sure it has something to do with the way double floating point numbers are stored, but I'm not sure quite what, and I don't know how to get around it!
Question
+Majesticmerc MVC
Hey all,
I'm developing an application at the moment, which uses some stochastic matrices. And I've hit something of a problem. The rows of the matrix must all add up to one, and they do, however when I sum the values in the row together I get 1.0000000000000002 as the result! How has this happened?
I'm fairly sure it has something to do with the way double floating point numbers are stored, but I'm not sure quite what, and I don't know how to get around it!
Help!
-- Majesticmerc
Link to comment
Share on other sites
9 answers to this question
Recommended Posts