Class DoubleEx
Class containing some extension methods for System.Double.
Inheritance
Inherited Members
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class DoubleEx
Methods
| Improve this Doc View SourceIsInfinity(Double)
Returns whether the specified number evaluates to negative or positive infinity.
Declaration
public static bool IsInfinity(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The double to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the given double is infinity, otherwise false. |
IsNaN(Double)
Returns whether the specified value is not a number.
Declaration
public static bool IsNaN(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The double to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the value is not a number, otherwise false. |
IsNegativeInfinity(Double)
Returns whether the specified number evaluates to negative infinity.
Declaration
public static bool IsNegativeInfinity(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The double to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the given double is negative infinity, otherwise false. |
IsPositiveInfinity(Double)
Returns whether the specified number evaluates to positive infinity.
Declaration
public static bool IsPositiveInfinity(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The double to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the given double is positive infinity, otherwise false. |
PercentageOf(Double, Double)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this double number, double percent)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The number. |
System.Double | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentageOf(Double, Int32)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this double number, int percent)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The number. |
System.Int32 | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentageOf(Double, Int64)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this double number, long percent)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The number. |
System.Int64 | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentOf(Double, Double)
Gets the percentage of the number.
Declaration
public static double PercentOf(this double number, double total)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The number. |
System.Double | total | The total value. |
Returns
Type | Description |
---|---|
System.Double | Returns the percentage of the number. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | The number must be greater than zero. |
PercentOf(Double, Int32)
Gets the percentage of the number.
Declaration
public static double PercentOf(this double number, int total)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The number. |
System.Int32 | total | The total value. |
Returns
Type | Description |
---|---|
System.Double | Returns the percentage of the number. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | The number must be greater than zero. |
PercentOf(Double, Int64)
Gets the percentage of the number.
Declaration
public static double PercentOf(this double number, long total)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The number. |
System.Int64 | total | The total value. |
Returns
Type | Description |
---|---|
System.Double | Returns the percentage of the number. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | The number must be greater than zero. |
Sum(Double, Double[])
Computes the sum of a sequence of the given values.
Declaration
public static double Sum(this double value, params double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The first value. |
System.Double[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Double | Returns the sum of the values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Double.MaxValue |
System.ArgumentNullException | values can not be null. |
Sum(Nullable<Double>, Nullable<Double>[])
Computes the sum of a sequence of the given values.
Declaration
public static double ? Sum(this double ? value, params double ? [] values)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<T><System.Double> | value | The first value. |
System.Nullable<T><System.Double>[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Nullable<T><System.Double> | Returns the sum of the values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Double.MaxValue |
System.ArgumentNullException | values can not be null. |
Sum<TSource>(TSource, Func<TSource, Double>, TSource[])
Computes the sum of the sequence of System.Double values that are obtained by invoking a transform function on each element of the input sequence.
Declaration
public static double Sum<TSource>(this TSource value, Func<TSource, double> selector, params TSource[] values)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The first value. |
System.Func<T, TResult><TSource, System.Double> | selector | A transform function to apply to each element. |
TSource[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Double | Returns the sum of the projected values. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Double.MaxValue |
System.ArgumentNullException | selector can not be null. |
Sum<TSource>(TSource, Func<TSource, Nullable<Double>>, TSource[])
Computes the sum of the sequence of nullable System.Double values that are obtained by invoking a transform function on each element of the input sequence.
Declaration
public static double ? Sum<TSource>(this TSource value, Func<TSource, double ? > selector, params TSource[] values)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The first value. |
System.Func<T, TResult><TSource, System.Nullable<T><System.Double>> | selector | A transform function to apply to each element. |
TSource[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Nullable<T><System.Double> | Returns the sum of the projected values. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Double.MaxValue |
System.ArgumentNullException | selector can not be null. |
ToDays(Double)
Returns the given Double value as day.
Declaration
public static TimeSpan ToDays(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The Double value. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns the given Double value as days. |
ToHours(Double)
Returns the given Double value as hours.
Declaration
public static TimeSpan ToHours(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The Double value. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns the given Double value as hours. |
ToMilliseconds(Double)
Returns the given Double value as milliseconds.
Declaration
public static TimeSpan ToMilliseconds(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The Double value. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns the given Double value as milliseconds. |
ToMinutes(Double)
Returns the given Double value as minutes.
Declaration
public static TimeSpan ToMinutes(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The Double value. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns the given Double value as minutes. |
ToSeconds(Double)
Returns the given Double value as seconds.
Declaration
public static TimeSpan ToSeconds(this double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The Double value. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns the given Double value as seconds. |