wp_fuzzy_number_match

The timeline below displays how wordpress function wp_fuzzy_number_match has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Checks if two numbers are nearly the same.
 *
 * This is similar to using `round()` but the precision is more fine-grained.
 *
 * @since 5.3.0
 *
 * @param int|float $expected  The expected value.
 * @param int|float $actual    The actual number.
 * @param int|float $precision Optional. The allowed variation. Default 1.
 * @return bool Whether the numbers match within the specified precision.
 */
function wp_fuzzy_number_match($expected, $actual, $precision = 1)
{
    return abs((float) $expected - (float) $actual) <= $precision;
}

WordPress Version: 6.1

/**
 * Checks if two numbers are nearly the same.
 *
 * This is similar to using `round()` but the precision is more fine-grained.
 *
 * @since 5.3.0
 *
 * @param int|float $expected  The expected value.
 * @param int|float $actual    The actual number.
 * @param int|float $precision The allowed variation.
 * @return bool Whether the numbers match within the specified precision.
 */
function wp_fuzzy_number_match($expected, $actual, $precision = 1)
{
    return abs((float) $expected - (float) $actual) <= $precision;
}

WordPress Version: 5.3

/**
 * Check if two numbers are nearly the same.
 *
 * This is similar to using `round()` but the precision is more fine-grained.
 *
 * @since 5.3.0
 *
 * @param int|float $expected  The expected value.
 * @param int|float $actual    The actual number.
 * @param int|float $precision The allowed variation.
 * @return bool Whether the numbers match whithin the specified precision.
 */
function wp_fuzzy_number_match($expected, $actual, $precision = 1)
{
    return abs((float) $expected - (float) $actual) <= $precision;
}