﻿<?xml version="1.0" encoding="utf-8"?><Type Name="AvoidFloatingPointEqualityRule" FullName="Gendarme.Rules.Correctness.AvoidFloatingPointEqualityRule"><TypeSignature Language="C#" Value="public class AvoidFloatingPointEqualityRule : Gendarme.Rules.Correctness.FloatingComparisonRule, Gendarme.Framework.IMethodRule" /><TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit AvoidFloatingPointEqualityRule extends Gendarme.Rules.Correctness.FloatingComparisonRule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" /><AssemblyInfo><AssemblyName>Gendarme.Rules.Correctness</AssemblyName><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Base><BaseTypeName>Gendarme.Rules.Correctness.FloatingComparisonRule</BaseTypeName></Base><Interfaces><Interface><InterfaceName>Gendarme.Framework.IMethodRule</InterfaceName></Interface></Interfaces><Attributes><Attribute><AttributeName>Gendarme.Framework.Problem("This method contains code that performs equality operations between floating point numbers.")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Solution("Instead use the absolute difference between the two floating point values and a small constant value.")</AttributeName></Attribute></Attributes><Docs><summary>
             In general floating point numbers cannot be usefully compared using the equality and
             inequality operators. This is because floating point numbers are inexact and most floating
             point operations introduce errors which can accumulate if multiple operations are performed.
             This rule will fire if [in]equality comparisons are used with <c>Single</c> or <c>Double</c> 
             types. In general such comparisons should be done with some sort of epsilon test instead
             of a simple compare (see the code below).
            
             For more information:
             <list><item><description>[http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm Floating Point Comparison (General Problem)]</description></item><item><description>[http://www.yoda.arachsys.com/csharp/floatingpoint.html Another article about floating point comparison (more .NET adapted)]</description></item></list></summary><remarks>Prior to Gendarme 2.2 this rule was named FloatComparisonRule.</remarks><example>
             Bad example:
             <code>
             // This may or may not work as expected. In particular, if the values are from
             // high precision real world measurements or different algorithmic sources then
             // it's likely that they will have small errors and an exact inequality test will not 
             // work as expected.
             public static bool NearlyEqual (double [] lhs, double [] rhs)
             {
             	if (ReferenceEquals (lhs, rhs)) {
             		return true;
             	}
             	if (lhs.Length != rhs.Length) {
             		return false;
             	}
             	for (int i = 0; i &lt; lhs.Length; ++i) {
             		if (lhs [i] != rhs [i]) {
             			return false;
             		}
             	}
             	return true;
             }
             </code></example><example>
             Good example:
             <code>
             // This will normally work fine. However it will not work with infinity (because
             // infinity - infinity is a NAN). It's also difficult to use if the values may 
             // have very large or very small magnitudes (because the epsilon value must 
             // be scaled accordingly).
             public static bool NearlyEqual (double [] lhs, double [] rhs, double epsilon)
             {
             	if (ReferenceEquals (lhs, rhs)) {
             		return true;
             	}
             	if (lhs.Length != rhs.Length) {
             		return false;
             	}
             	for (int i = 0; i &lt; lhs.Length; ++i) {
             		if (Math.Abs (lhs [i] - rhs [i]) &gt; epsilon) {
             			return false;
             			}
             	}
             	return true;
             }
             </code></example></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public AvoidFloatingPointEqualityRule ();" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Parameters /><Docs><summary>To be added.</summary><remarks>To be added.</remarks></Docs></Member><Member MemberName="CheckMethod"><MemberSignature Language="C#" Value="public Gendarme.Framework.RuleResult CheckMethod (Mono.Cecil.MethodDefinition method);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance valuetype Gendarme.Framework.RuleResult CheckMethod(class Mono.Cecil.MethodDefinition method) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>Gendarme.Framework.RuleResult</ReturnType></ReturnValue><Parameters><Parameter Name="method" Type="Mono.Cecil.MethodDefinition" /></Parameters><Docs><param name="method">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks></Docs></Member></Members></Type>