wp_fuzzy_number_match( int|float $expected, int|float $actual, int|float $precision = 1 )
Checks if two numbers are nearly the same.
Description
This is similar to using round()
but the precision is more fine-grained.
Parameters
- $expected
-
(Required) The expected value.
- $actual
-
(Required) The actual number.
- $precision
-
(Optional) The allowed variation.
Default value: 1
Return
(bool) Whether the numbers match within the specified precision.
Source
File: wp-includes/functions.php
function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
return abs( (float) $expected - (float) $actual ) <= $precision;
}
Changelog
Version | Description |
---|---|
5.3.0 | Introduced. |