wp_fuzzy_number_match( int|float $expected, int|float $actual, int|float $precision = 1 )

Check if two numbers are nearly the same.


Description Description

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


Parameters Parameters

$expected

(int|float) (Required) The expected value.

$actual

(int|float) (Required) The actual number.

$precision

(int|float) (Optional) The allowed variation.

Default value: 1


Top ↑

Return Return

(bool) Whether the numbers match whithin the specified precision.


Top ↑

Source Source

File: wp-includes/functions.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
5.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.