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
n
DoubleThe positive integer to calculate a factorial number by.
Returns
- Double
The factorial number calculated from
n
, or PositiveInfinity ifn
is to high a value.
Exceptions
- ArgumentOutOfRangeException
n
is 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
value
DoubleA double-precision floating-point number to be rounded.
accuracy
RoundOffAccuracyThe accuracy to use in the rounding.
Returns
- Double
The integer value closest to the specified
accuracy
ofvalue
.
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
value
DoubleThe value to be converted.
timeUnit
TimeUnitOne of the enumeration values that specifies the outcome of the conversion.
Returns
Exceptions
- OverflowException
The
value
paired withtimeUnit
is outside its valid range.- ArgumentOutOfRangeException
timeUnit
was outside its valid range.