Class MathExtensions
Defines a collection of extensions for common mathematics expressions.
Inheritance
Namespace: MADE.Data.Validation.Extensions
Assembly: MADE.Data.Validation.dll
Syntax
public static class MathExtensions : object
Fields
| Improve this Doc View SourceEpsilon
Gets a value for Epsilon.
Declaration
public static readonly double Epsilon
Field Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceIsCloseTo(Double, Double)
Checks whether two values are close in value which have a precision point.
Declaration
public static bool IsCloseTo(this double value, double compare)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The first value. |
System.Double | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the values are close; otherwise, false. |
IsCloseTo(Int32, Int32)
Checks whether two values are close in value.
Declaration
public static bool IsCloseTo(this int value, int compare)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The first value. |
System.Int32 | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the values are close; otherwise, false. |
IsCloseTo(Nullable<Double>, Nullable<Double>)
Checks whether two values are close in value which have a precision point.
Declaration
public static bool IsCloseTo(this double? value, double? compare)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Double> | value | The first value. |
System.Nullable<System.Double> | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the values are close; otherwise, false. |
IsCloseTo(Nullable<Single>, Nullable<Single>)
Checks whether two values are close in value which have a precision point.
Declaration
public static bool IsCloseTo(this float? value, float? compare)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Single> | value | The first value. |
System.Nullable<System.Single> | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the values are close; otherwise, false. |
IsCloseTo(Single, Single)
Checks whether two values are close in value which have a precision point.
Declaration
public static bool IsCloseTo(this float value, float compare)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The first value. |
System.Single | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the values are close; otherwise, false. |
IsGreaterThan(Double, Double)
Checks whether a value is significantly greater than another.
Declaration
public static bool IsGreaterThan(this double value, double compare)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The first value. |
System.Double | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the first value is greater than the second; otherwise, false. |
IsInRange(Double, Double, Double)
Checks whether a value is within a range.
Declaration
public static bool IsInRange(this double value, double lower, double upper)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value to check is in range. |
System.Double | lower | The lower range band. |
System.Double | upper | The upper range band. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is in the range; otherwise, false. |
Exceptions
Type | Condition |
---|---|
InvalidRangeException | Thrown if the range is invalid. |
IsInRange(Int32, Int32, Int32)
Checks whether a value is within a range.
Declaration
public static bool IsInRange(this int value, int lower, int upper)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to check is in range. |
System.Int32 | lower | The lower range band. |
System.Int32 | upper | The upper range band. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is in the range; otherwise, false. |
Exceptions
Type | Condition |
---|---|
InvalidRangeException | Thrown if the range is invalid. |
IsInRange(Single, Single, Single)
Checks whether a value is within a range.
Declaration
public static bool IsInRange(this float value, float lower, float upper)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The value to check is in range. |
System.Single | lower | The lower range band. |
System.Single | upper | The upper range band. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is in the range; otherwise, false. |
Exceptions
Type | Condition |
---|---|
InvalidRangeException | Thrown if the range is invalid. |
IsLessThan(Double, Double)
Checks whether a value is significantly less than another.
Declaration
public static bool IsLessThan(this double value, double compare)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The first value. |
System.Double | compare | The second value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the first value is less than the second; otherwise, false. |
IsZero(Double)
Checks whether a double value is zero.
Declaration
public static bool IsZero(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if zero; otherwise, false. |
IsZero(Single)
Checks whether a float value is zero.
Declaration
public static bool IsZero(this float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if zero; otherwise, false. |