Class NumberUtilityExtensions
This is an extension implementation of the most common methods on the NumberUtility class.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class NumberUtilityExtensions
Methods
| Improve this DocBytesToGigabytes(Int64)
Converts the specified bytes
to its equivalent representation in gigabytes.
Declaration
public static double BytesToGigabytes(this long bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | The bytes to be converted. |
Returns
Type | Description |
---|---|
System.Double | A gigabyte representation equivalent to the specified |
BytesToKilobytes(Int64)
Converts the specified bytes
to its equivalent representation in kilobytes.
Declaration
public static double BytesToKilobytes(this long bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | The bytes to be converted. |
Returns
Type | Description |
---|---|
System.Double | A kilobyte representation equivalent to the specified |
BytesToMegabytes(Int64)
Converts the specified bytes
to its equivalent representation in megabytes.
Declaration
public static double BytesToMegabytes(this long bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | The bytes to be converted. |
Returns
Type | Description |
---|---|
System.Double | A megabyte representation equivalent to the specified |
BytesToTerabytes(Int64)
Converts the specified bytes
to its equivalent representation in terabytes.
Declaration
public static double BytesToTerabytes(this long bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | The bytes to be converted. |
Returns
Type | Description |
---|---|
System.Double | A terabyte representation equivalent to the specified |
Factorial(Double)
Calculates the factorial of a positive integer n
denoted by n!.
Declaration
public static double Factorial(this double n)
Parameters
Type | Name | Description |
---|---|---|
System.Double | n | The positive integer to calculate a factorial number by. |
Returns
Type | Description |
---|---|
System.Double | The factorial number calculated from |
IsCountableSequence(IEnumerable<Int32>)
Determines whether the specified source
is a sequence of countable integrals (hence, integrals being either incremented or decremented with the same cardinality through out the sequence).
Declaration
public static bool IsCountableSequence(this IEnumerable<int> source)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | source | The value to test for a sequence of countable characters. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsCountableSequence(IEnumerable<Int64>)
Determines whether the specified source
is a sequence of countable integrals (hence, integrals being either incremented or decremented with the same cardinality through out the sequence).
Declaration
public static bool IsCountableSequence(this IEnumerable<long> source)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int64> | source | The value to test for a sequence of countable characters. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsEven(Int32)
Determines whether the specified value
is an even number.
Declaration
public static bool IsEven(this int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to evaluate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsOdd(Int32)
Determines whether the specified value
is an odd number.
Declaration
public static bool IsOdd(this int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to evaluate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsPrime(Int32)
Determines whether the specified value
is a prime number.
Declaration
public static bool IsPrime(this int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The positive integer to determine whether is a prime number. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
RoundOff(Double, RoundOffAccuracy)
Rounds a double-precision floating-point value to the nearest integral value closest to the specified accuracy
.
Declaration
public static double RoundOff(this double value, RoundOffAccuracy accuracy)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | A double-precision floating-point number to be rounded. |
RoundOffAccuracy | accuracy | The accuracy to use in the rounding. |
Returns
Type | Description |
---|---|
System.Double | The integer value closest to the specified |