Class DoubleExtensions
- Namespace
- Cuemon.Extensions
- Assembly
- Cuemon.Extensions.Core.dll
Extension methods for the double struct.
public static class DoubleExtensions
- Inheritance
-
DoubleExtensions
Methods
Factorial(double)
Calculates the factorial of a positive integer n denoted by n!.
public static double Factorial(this double n)
Parameters
ndoubleThe positive integer to calculate a factorial number by.
Returns
- double
The factorial number calculated from
n, or PositiveInfinity ifnis to high a value.
Exceptions
- ArgumentOutOfRangeException
nis lower than 0.
FromUnixEpochTime(double)
Converts the specified input of an UNIX Epoch time to its equivalent DateTime structure.
public static DateTime FromUnixEpochTime(this double input)
Parameters
Returns
RoundOff(double, RoundOffAccuracy)
Rounds a double-precision floating-point value to the nearest integral value closest to the specified accuracy.
public static double RoundOff(this double value, RoundOffAccuracy accuracy)
Parameters
valuedoubleA double-precision floating-point number to be rounded.
accuracyRoundOffAccuracyThe accuracy to use in the rounding.
Returns
- double
The integer value closest to the specified
accuracyofvalue.
Note that this method returns a double instead of an integral type.
ToTimeSpan(double, TimeUnit)
Converts the specified value to its equivalent TimeSpan representation.
public static TimeSpan ToTimeSpan(this double value, TimeUnit timeUnit)
Parameters
valuedoubleThe value to be converted.
timeUnitTimeUnitOne of the enumeration values that specifies the outcome of the conversion.
Returns
Exceptions
- OverflowException
The
valuepaired withtimeUnitis outside its valid range.- ArgumentOutOfRangeException
timeUnitwas outside its valid range.