[#BloombergLP-bdlb-DoubleCompareUtil-fuzzyCompare-028]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/DoubleCompareUtil.adoc[DoubleCompareUtil]::fuzzyCompare
:relfileprefix: ../../../
:mrdocs:

Return the fuzzy comparison result of two `double` values&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;doublecompareutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
xref:BloombergLP/bdlb/DoubleCompareUtil/CompareResult.adoc[DoubleCompareUtil::CompareResult]
fuzzyCompare(
    double a,
    double b);
----

== Description

Return `e&lowbar;EQUAL` if the specified `a` and `b` have fuzzy equality, `e&lowbar;GREATER&lowbar;THAN` if `a &gt; b`, `e&lowbar;LESS&lowbar;THAN` if `a &lt; b`, and `e&lowbar;NON&lowbar;COMPARABLE` if either `a` or `b` are a NaN&period; Optionally specify the relative tolerance `relTol`, or `relTol` and the absolute tolerance `absTol`, used to determine fuzzy equality&period; If an optional tolerance argument is not specified, a reasonable (implementation&hyphen;dependent) default value for that tolerance is used&period; Fuzzy equality (denoted &quot;a &#126;eq b&quot;) between a and b is defined in terms of the relative tolerance `relTol` and the absolute tolerance `absTol` such that the expression&colon; &grave; a &equals;&equals; b &verbar;&verbar; fabs(a &hyphen; b) &lt;&equals; absTol &verbar;&verbar; fabs(a &hyphen; b) &sol; fabs((a &plus; b) &sol; 2&period;0) &lt;&equals; relTol &grave; is `true`&semi; however, in the special case where `a !&equals; 0 &amp;&amp; a &equals;&equals; &hyphen;b` is `true`, the actual relative difference is effectively infinite, and no value of `relTol` can imply fuzzy equality (although a sufficiently large value of `absTol` can)&period; Note that if either `absTol` or `relTol` is 0&period;0, that aspect of fuzzy comparison is effectively suppressed, but the behavior of this function is defined&period; The behavior is undefined unless both `relTol` and `absTol` are non&hyphen;negative, finite numbers (which excludes NaN and infinity)&period; Note also that the primary purpose of this public static comparison method is to implement the six fuzzy equality and relational functions also defined within this utility `struct` (see `fuzzyEq`, `fuzzyNe`, `fuzzyLt`, `fuzzyLe`, `fuzzyGt`, and `fuzzyGe`)&period;

== Return Value

the fuzzy comparison result of `a` and `b`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *a*
| first value to compare
| *b*
| second value to compare
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
