Show / Hide Table of Contents

Class Common

Contains general-purpose mathematical operations.

Inheritance
object
Common
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Math
Assembly: MCART.dll
Syntax
public static class Common

Methods

| Edit this page View Source

Clamp(in double, in double)

Limits the range of an expression to prevent overflow.

Declaration
public static double Clamp(this in double expression, in double max)
Parameters
Type Name Description
double expression

The expression to evaluate.

double max

The upper bound of the output range, inclusive.

Returns
Type Description
double

The evaluated value within the specified range.

Remarks

This implementation is included to allow parameters of type NaN, NegativeInfinity, and PositiveInfinity.

| Edit this page View Source

Clamp(in double, in double, in double)

Limits the range of an expression to prevent overflow.

Declaration
public static double Clamp(this in double expression, in double min, in double max)
Parameters
Type Name Description
double expression

The expression to evaluate.

double min

The lower bound of the output range, inclusive.

double max

The upper bound of the output range, inclusive.

Returns
Type Description
double

The evaluated value within the specified range.

Remarks

This implementation is included to allow parameters of type NaN, NegativeInfinity, and PositiveInfinity.

| Edit this page View Source

Clamp(in float, in float)

Limits the range of an expression to prevent overflow.

Declaration
public static float Clamp(this in float expression, in float max)
Parameters
Type Name Description
float expression

The expression to evaluate.

float max

The upper bound of the output range, inclusive.

Returns
Type Description
float

The evaluated value within the specified range.

Remarks

This implementation is included to allow parameters of type NaN, NegativeInfinity, and PositiveInfinity.

| Edit this page View Source

Clamp(in float, in float, in float)

Limits the range of an expression to prevent overflow.

Declaration
public static float Clamp(this in float expression, in float min, in float max)
Parameters
Type Name Description
float expression

The expression to evaluate.

float min

The lower bound of the output range, inclusive.

float max

The upper bound of the output range, inclusive.

Returns
Type Description
float

The evaluated value within the specified range.

Remarks

This implementation is included to allow parameters of type NaN, NegativeInfinity, and PositiveInfinity.

| Edit this page View Source

Clamp<T>(T, in T)

Limits the range of an expression to prevent overflow.

Declaration
public static T Clamp<T>(this T expression, in T max) where T : struct, IComparable<T>
Parameters
Type Name Description
T expression

The expression to evaluate.

T max

The upper bound of the output range, inclusive.

Returns
Type Description
T

The evaluated value between 0 and max.

Type Parameters
Name Description
T

The type of expression to limit.

| Edit this page View Source

Clamp<T>(T, in T, in T)

Limits the range of an expression to prevent overflow.

Declaration
public static T Clamp<T>(this T expression, in T min, in T max) where T : IComparable<T>
Parameters
Type Name Description
T expression

The expression to evaluate.

T min

The lower bound of the output range, inclusive.

T max

The upper bound of the output range, inclusive.

Returns
Type Description
T

The evaluated value that falls within the specified range.

Type Parameters
Name Description
T

The type of expression to limit.

| Edit this page View Source

OrIfInvalid(in double, in double)

Checks if a value is a valid, operable double-precision number. Returns the value if valid; otherwise, returns an alternate value.

Declaration
public static double OrIfInvalid(this in double value, in double alternateValue)
Parameters
Type Name Description
double value

Value to check.

double alternateValue

Value to return if value is invalid.

Returns
Type Description
double

value if it's a valid, operable double, alternateValue otherwise.

| Edit this page View Source

OrIfInvalid(in double, Func<double>)

Checks if a value is a valid, operable double-precision number. Returns the value if valid; otherwise, returns an alternate value.

Declaration
public static double OrIfInvalid(this in double value, Func<double> alternateFunc)
Parameters
Type Name Description
double value

Value to check.

Func<double> alternateFunc

Function that returns the value to return if value is invalid.

Returns
Type Description
double

value if it's a valid, operable double, or the result of alternateFunc otherwise.

| Edit this page View Source

OrIfInvalid(in float, Func<float>)

Checks if a value is a valid, operable floating-point number. Returns the value if valid; otherwise, returns an alternate value.

Declaration
public static float OrIfInvalid(this in float value, Func<float> alternateFunc)
Parameters
Type Name Description
float value

Value to check.

Func<float> alternateFunc

Function that returns the value to return if value is invalid.

Returns
Type Description
float

value if it's a valid, operable float, or the result of alternateFunc otherwise.

| Edit this page View Source

OrIfInvalid(in float, in float)

Checks if a value is a valid, operable floating-point number. Returns the value if valid; otherwise, returns an alternate value.

Declaration
public static float OrIfInvalid(this in float value, in float alternateValue)
Parameters
Type Name Description
float value

Value to check.

float alternateValue

Value to return if value is invalid.

Returns
Type Description
float

value if it's a valid, operable float, alternateValue otherwise.

| Edit this page View Source

Wrap(in byte, in byte, in byte)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static byte Wrap(this in byte expression, in byte min, in byte max)
Parameters
Type Name Description
byte expression

Expression to evaluate.

byte min

Lower bound of the output range, inclusive.

byte max

Upper bound of the output range, inclusive.

Returns
Type Description
byte

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in char, in char, in char)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static int Wrap(this in char expression, in char min, in char max)
Parameters
Type Name Description
char expression

Expression to evaluate.

char min

Lower bound of the output range, inclusive.

char max

Upper bound of the output range, inclusive.

Returns
Type Description
int

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in decimal, in decimal, in decimal)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static decimal Wrap(this in decimal expression, in decimal min, in decimal max)
Parameters
Type Name Description
decimal expression

Expression to evaluate.

decimal min

Lower bound of the output range, inclusive.

decimal max

Upper bound of the output range, inclusive.

Returns
Type Description
decimal

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in double, in double, in double)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static double Wrap(this in double expression, in double min, in double max)
Parameters
Type Name Description
double expression

Expression to evaluate.

double min

Lower bound of the output range, inclusive.

double max

Upper bound of the output range, inclusive.

Returns
Type Description
double

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in short, in short, in short)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static int Wrap(this in short expression, in short min, in short max)
Parameters
Type Name Description
short expression

Expression to evaluate.

short min

Lower bound of the output range, inclusive.

short max

Upper bound of the output range, inclusive.

Returns
Type Description
int

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in int, in int, in int)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static int Wrap(this in int expression, in int min, in int max)
Parameters
Type Name Description
int expression

Expression to evaluate.

int min

Lower bound of the output range, inclusive.

int max

Upper bound of the output range, inclusive.

Returns
Type Description
int

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in long, in long, in long)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static long Wrap(this in long expression, in long min, in long max)
Parameters
Type Name Description
long expression

Expression to evaluate.

long min

Lower bound of the output range, inclusive.

long max

Upper bound of the output range, inclusive.

Returns
Type Description
long

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in sbyte, in sbyte, in sbyte)

Intentionally sets overflow points to evaluate an expression.

Declaration
[CLSCompliant(false)]
public static int Wrap(this in sbyte expression, in sbyte min, in sbyte max)
Parameters
Type Name Description
sbyte expression

Expression to evaluate.

sbyte min

Lower bound of the output range, inclusive.

sbyte max

Upper bound of the output range, inclusive.

Returns
Type Description
int

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in float, in float, in float)

Intentionally sets overflow points to evaluate an expression.

Declaration
public static float Wrap(this in float expression, in float min, in float max)
Parameters
Type Name Description
float expression

Expression to evaluate.

float min

Lower bound of the output range, inclusive.

float max

Upper bound of the output range, inclusive.

Returns
Type Description
float

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in ushort, in ushort, in ushort)

Intentionally sets overflow points to evaluate an expression.

Declaration
[CLSCompliant(false)]
public static int Wrap(this in ushort expression, in ushort min, in ushort max)
Parameters
Type Name Description
ushort expression

Expression to evaluate.

ushort min

Lower bound of the output range, inclusive.

ushort max

Upper bound of the output range, inclusive.

Returns
Type Description
int

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in uint, in uint, in uint)

Intentionally sets overflow points to evaluate an expression.

Declaration
[CLSCompliant(false)]
public static uint Wrap(this in uint expression, in uint min, in uint max)
Parameters
Type Name Description
uint expression

Expression to evaluate.

uint min

Lower bound of the output range, inclusive.

uint max

Upper bound of the output range, inclusive.

Returns
Type Description
uint

The evaluated value that is within the specified range.

| Edit this page View Source

Wrap(in ulong, in ulong, in ulong)

Intentionally sets overflow points to evaluate an expression.

Declaration
[CLSCompliant(false)]
public static ulong Wrap(this in ulong expression, in ulong min, in ulong max)
Parameters
Type Name Description
ulong expression

Expression to evaluate.

ulong min

Lower bound of the output range, inclusive.

ulong max

Upper bound of the output range, inclusive.

Returns
Type Description
ulong

The evaluated value that is within the specified range.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX