New to Telerik UI for .NET MAUIStart a free 30-day trial

RadMath

Class

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:

C#
public static class RadMath

Inheritance: objectRadMath

Fields

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

C#
public const double Epsilon = 0.001

Methods

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

C#
public static bool AreClose(double num1, double num2, double epsilon = 0.001)
Parameters:num1double

The first number to compare.

num2double

The second number to compare.

epsilondouble

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.

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.

C#
public static bool AreClose2(double num1, double num2, double epsilon = 0.001)
Parameters:num1double

The first number to compare.

num2double

The second number to compare.

epsilondouble

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.

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

C#
public static bool IsInRange<T>(T value, T min, T max) where T : IComparable
Parameters:valueT

The value to check.

minT

The minimum value of the range (inclusive).

maxT

The maximum value of the range (inclusive).

Returns:

bool

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