Friday, October 02, 2009

Yet Another Reason To Hate Floats

Ok, so I stole that line from Strilanc on the Microsoft Code Contract Forum  but he has a point. This is another one of those things that makes me want to stop writing code.

So, what’s the problem ? Well it would appear that comparing a parameter of type double with a field of type double won’t necessarily end up with matching values, even after the field has been set equal to the parameter. For the actual details of the problem see this;

False Warning: Possible precision mismatch for the arguments of ==

A better question would be why doesn’t the compiler generate a warning for this ? You can just imagine some poor developer somewhere scratching his head over why this doesn’t work, or worse, only doesn’t work in production… it hardly seems to be a well known or obvious issue.

Technorati Tags: ,,

No comments:

Post a comment