wp_fuzzy_number_match()WP 5.3.0

Checks if two numbers are nearly the same.

This is similar to using round() but the precision is more fine-grained.

No Hooks.


true|false. Whether the numbers match within the specified precision.


wp_fuzzy_number_match( $expected, $actual, $precision );
$expected(int|float) (required)
The expected value.
$actual(int|float) (required)
The actual number.
The allowed variation.
Default: 1


Since 5.3.0 Introduced.

wp_fuzzy_number_match() code WP 6.5.4

function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
	return abs( (float) $expected - (float) $actual ) <= $precision;