On this page
wp_fuzzy_number_match( int|float $expected, int|float $actual, int|float $precision = 1 ): bool
Checks if two numbers are nearly the same.
Description
This is similar to using round() but the precision is more fine-grained.
Parameters
$expectedint|float Required-
The expected value.
$actualint|float Required-
The actual number.
$precisionint|float Optional-
The allowed variation.
Default:
1
Return
bool Whether the numbers match within the specified precision.
Source
File: wp-includes/functions.php. View all references
function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
return abs( (float) $expected - (float) $actual ) <= $precision;
}
Related
Used By
| Used By | Description |
|---|---|
| wp_image_matches_ratio() wp-includes/media.php | Helper function to test if aspect ratios for two images match. |
| image_resize_dimensions() wp-includes/media.php | Retrieves calculated resize dimensions for use in WP_Image_Editor. |
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_fuzzy_number_match