Class
RadMath

Provides mathematical utility methods and constants. This static class contains various mathematical operations, comparisons, conversions, and calculations.

Definition

Namespace:Telerik.Maui

Assembly:Telerik.Maui.Core.dll

Syntax:

cs-api-definition
public static class RadMath

Inheritance: objectRadMath

Fields

Epsilon

The default epsilon value used for floating-point comparisons. This constant represents the minimum difference threshold for considering two double values as equal.

Declaration

cs-api-definition
public const double Epsilon = 0.001

Field Value

double

Methods

AreClose(double, double, double)

Determines whether two double values are approximately equal within the specified epsilon tolerance.

Declaration

cs-api-definition
public static bool AreClose(double num1, double num2, double epsilon = 0.001)

Parameters

num1

double

The first number to compare.

num2

double

The second number to compare.

epsilon

double

The epsilon tolerance for the comparison. Defaults to Epsilon.

Returns

bool

true if the absolute difference between the numbers is less than or equal to epsilon; otherwise, false.

AreClose2(double, double, double)

Determines whether two double values are approximately equal using relative epsilon comparison. This method uses the relative difference between the numbers divided by their sum.

Declaration

cs-api-definition
public static bool AreClose2(double num1, double num2, double epsilon = 0.001)

Parameters

num1

double

The first number to compare.

num2

double

The second number to compare.

epsilon

double

The epsilon tolerance for the comparison. Defaults to Epsilon.

Returns

bool

true if the relative difference between the numbers is less than or equal to epsilon; otherwise, false.

IsInRange<T>(T, T, T)

Determines whether a value is within the specified range (inclusive).

Declaration

cs-api-definition
public static bool IsInRange<T>(T value, T min, T max) where T : IComparable

Parameters

value

T

The value to check.

min

T

The minimum value of the range (inclusive).

max

T

The maximum value of the range (inclusive).

Returns

bool

true if the value is within the range [min, max]; otherwise, false.