Infinite Value Public API
MathInfVal
namespace: InfiniteValue
A static class containing methods allowing you to do mathematical operations on an InfVal.
static Methods
Abs Returns the absolute value of an InfVal.
public static InfVal Abs(in InfVal value)
Returns the absolute value of an InfVal.
The result will always be positive or zero.
Approximately Compares two InfVal and returns true if they are similar.
public static bool Approximately(in InfVal a, in InfVal b, int precision)
Compares two InfVal and returns true if they are similar.
Clamp Clamps an InfVal between the given minimum and maximum values.
public static bool Clamp(in InfVal value, in InfVal min, in InfVal max)
Clamps an InfVal between the given minimum and maximum values.
The result will be min, max, or a value in between.
Clamp01 Clamps an InfVal between 0 and 1.
public static InfVal Clamp01(in InfVal value)
Clamps an InfVal between 0 and 1.
The result will be 0, 1, or a value in between.
ClosestPowerOfTwo Returns the closest power of 2 of an InfVal.
public static InfVal ClosestPowerOfTwo(in InfVal value)
Returns the closest power of 2 of an InfVal.
This will return the argument if it is already a power of two.
This will return 0 if the argument is strictly negative.
The returned InfVal will always have an exponent of 0.
NextPowerOfTwo Returns the next power of 2 that is equal to, or greater than, the argument.
public static InfVal NextPowerOfTwo(in InfVal value)
Returns the next power of 2 that is equal to, or greater than, the argument.
This will return the argument if it is already a power of two.
This will return 0 if the argument is strictly negative.
The returned InfVal will always have an exponent of 0.
PreviousPowerOfTwo Returns the previous power of 2 that is equal to, or lower than, the argument.
public static InfVal PreviousPowerOfTwo(in InfVal value)
Returns the previous power of 2 that is equal to, or lower than, the argument.
This will return the argument if it is already a power of two.
This will return 0 if the argument is strictly negative.
The returned InfVal will always have an exponent of 0.
Repeat Loops the value t, so that it is never larger than length and never smaller than 0.
public static InfVal Repeat(in InfVal t, in InfVal length)
Loops the value t, so that it is never larger than length and never smaller than 0.
PingPong PingPong returns a value that will increment and decrement between the value 0 and length.
public static InfVal PingPong(in InfVal t, in InfVal length)
PingPong returns a value that will increment and decrement between the value 0 and length.
DeltaAngle Calculates the shortest difference between two given angles given in degrees.
public static InfVal DeltaAngle(in InfVal current, in InfVal target)
Calculates the shortest difference between two given angles given in degrees.
Log Returns the logarithm of a specified InfVal.
public static double Log(in InfVal value)
Returns the natural logarithm (base e) of a specified InfVal.
public static double Log(in InfVal value, double b)
Returns the logarithm of a specified InfVal in a specified base.
Log10 Returns the base 10 logarithm of a specified InfVal.
public static double Log10(in InfVal value)
Returns the base 10 logarithm of a specified InfVal.
This is more performant than using Log(value, 10).
Floor Returns the largest integer smaller than or equal to an InfVal.
public static InfVal Floor(in InfVal value)
Returns the largest integer smaller than or equal to an InfVal.
The returned InfVal exponent will be the same as the argument.
Ceil Returns the smallest integer greater to or equal to an InfVal.
public static InfVal Ceil(in InfVal value)
Returns the smallest integer greater to or equal to an InfVal.
The returned InfVal exponent will be the same as the argument.
Round Returns an InfVal rounded to the nearest integer.
public static InfVal Round(in InfVal value)
Returns an InfVal rounded to the nearest integer.
The returned InfVal exponent will be the same as the argument.
Max Returns the largest of two or more values.
public static InfVal Max(in InfVal a, in InfVal b)
public static InfVal Max(params InfVal[] values)
Returns the largest of two or more values.
This will throw an exception if used with no arguments.
Min Returns the smallest of two or more values.
public static InfVal Min(in InfVal a, in InfVal b)
public static InfVal Min(params InfVal[] values)
Returns the smallest of two or more values.
This will throw an exception if used with no arguments.
MaxExponent Returns the value with the highest exponent.
public static InfVal MaxExponent(in InfVal a, in InfVal b)
public static InfVal MaxExponent(params InfVal[] values)
Returns the value with the highest exponent.
This will throw an exception if used with no arguments.
MinExponent Returns the value with the lowest exponent.
public static InfVal MinExponent(in InfVal a, in InfVal b)
public static InfVal MinExponent(params InfVal[] values)
Returns the value with the lowest exponent.
This will throw an exception if used with no arguments.
MaxPrecision Returns the value with the highest precision.
public static InfVal MaxPrecision(in InfVal a, in InfVal b)
public static InfVal MaxPrecision(params InfVal[] values)
Returns the value with the highest precision.
This will throw an exception if used with no arguments.
MinPrecision Returns the value with the lowest precision.
public static InfVal MinPrecision(in InfVal a, in InfVal b)
public static InfVal MinPrecision(params InfVal[] values)
Returns the value with the lowest precision.
This will throw an exception if used with no arguments.
Pow Returns an InfVal raised to an integer power.
public static InfVal Pow(in InfVal value, int power, bool conservePrecision = true)
Returns value raised to power.
Optionally define wether the result should have the same precision as the given value.
Sqrt Returns the square root of an InfVal.
public static InfVal Sqrt(in InfVal value, bool conservePrecision = true)
Returns the square root of value.
Optionally define wether the result should have the same precision as the given value.
This will throw an exception if value is strictly negative.
NthRoot Returns the Nth root of an InfVal.
public static InfVal NthRoot(in InfVal value, int n, bool conservePrecision = true)
Returns the Nth root of value. (The number that raised to n will equal value).
Optionally define wether the result should have the same precision as the given value.
This will throw an exception if used with n equals to 0.
This will throw an exception if used with a strictly negative value and an even n.
Truncate Calculates the integral part of a value.
public static InfVal Truncate(in InfVal value)
Calculates the integral part of a value.
The returned InfVal will have the same exponent as the value argument.
DecimalPart Calculates the decimal part of a value.
public static InfVal DecimalPart(in InfVal value)
Calculates the decimal part of a value.
The returned InfVal will have the same exponent as the value argument.
GreatestCommonDivisor Finds the greatest common divisor of two InfVal.
public static InfVal GreatestCommonDivisor(in InfVal a, in InfVal b)
Finds the greatest common divisor of two InfVal. The result exponent will be the lowest of the two arguments.
RandomRange Return a random value between min and max.
public static InfVal RandomRange(in InfVal min, in InfVal max)
Return a random value between min [inclusive] and max [inclusive].