AvoidFloatingPointEqualityRule

6 views
Skip to first unread message

Vlad

unread,
Oct 19, 2009, 1:17:34 PM10/19/09
to Gendarme
My code got flagged for doing what is suggested. What is wrong with
the following code?

return (Math.Abs(definitionValue - actualValue) < float.Epsilon);

P.S. Any chance on bringing the MonoDevelop Add-in up to date?

Thanks!

Sebastien Pouliot

unread,
Oct 19, 2009, 5:43:23 PM10/19/09
to gend...@googlegroups.com
On Mon, 2009-10-19 at 10:17 -0700, Vlad wrote:
> My code got flagged for doing what is suggested. What is wrong with
> the following code?
>
> return (Math.Abs(definitionValue - actualValue) < float.Epsilon);

The solution is a bit more complex than that and the rule documentation
is updated for 2.6 (but not yet on the wiki). I don't recall the rule
source enough to see why it fails... I'll check that up later (likely
next weekend).

Not that opening a bug report (on bugzilla.novell.com) is a good way to
make sure I won't forget about it :)

> P.S. Any chance on bringing the MonoDevelop Add-in up to date?

No, unless someone step up to the task. Got a itch to scratch ? ;-)

Most Gendarme contributors don't know much about MD internals - but have
promised much help to anyone willing to contribute working on this.
Actually Michael and me discussed this a few times so we have a (or
some) very good idea(s) about it (sadly much more ideas than time to do
it)

Sebastien

Reply all
Reply to author
Forward
0 new messages