Table of Contents

Class DoubleExtensions

Namespace
Cuemon.Extensions
Assembly
Cuemon.Extensions.Core.dll

Extension methods for the System.Double struct.

public static class DoubleExtensions
Inheritance
Object
DoubleExtensions

Methods

Factorial(Double)

Calculates the factorial of a positive integer n denoted by n!.

public static double Factorial(this double n)

Parameters

n Double

The positive integer to calculate a factorial number by.

Returns

Double

The factorial number calculated from n, or System.Double.PositiveInfinity if n is to high a value.

Exceptions

System.ArgumentOutOfRangeException

n is lower than 0.

FromUnixEpochTime(Double)

Converts the specified input of an UNIX Epoch time to its equivalent System.DateTime structure.

public static DateTime FromUnixEpochTime(this double input)

Parameters

input Double

The System.Double to extend.

Returns

DateTime

A System.DateTime that is equivalent to input.

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 Double

A double-precision floating-point number to be rounded.

accuracy RoundOffAccuracy

The accuracy to use in the rounding.

Returns

Double

The integer value closest to the specified accuracy of value.
Note that this method returns a System.Double instead of an integral type.

ToTimeSpan(Double, TimeUnit)

Converts the specified value to its equivalent System.TimeSpan representation.

public static TimeSpan ToTimeSpan(this double value, TimeUnit timeUnit)

Parameters

value Double

The value to be converted.

timeUnit TimeUnit

One of the enumeration values that specifies the outcome of the conversion.

Returns

TimeSpan

A System.TimeSpan that corresponds to value from timeUnit.

Exceptions

System.OverflowException

The value paired with timeUnit is outside its valid range.

System.ArgumentOutOfRangeException

timeUnit was outside its valid range.