Class XLong
Extension methods for long.
Inheritance
System.Object
XLong
Namespace: Galaxon.Core.Numbers
Assembly: Galaxon.Core.dll
Syntax
public static class XLong : object
Methods
Abs(Int64)
Return the absolute value of a long as a ulong. This addresses an issue with long.Abs(), which is that Abs(long.MinValue) can't be expressed as a long, and so wrap-around occurs. Unsigned integer types don't have an Abs() method, so there's no collision.
Declaration
public static ulong Abs(long n)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | n | A long value. |
Returns
| Type | Description |
|---|---|
| System.UInt64 | The absolute value as a ulong. |
GetRandom()
Get a random long.
Declaration
public static long GetRandom()
Returns
| Type | Description |
|---|---|
| System.Int64 |
Pow(Int64, Int64)
Get the long value closest to x^y.
Declaration
public static long Pow(long x, long y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | x | |
| System.Int64 | y |
Returns
| Type | Description |
|---|---|
| System.Int64 |
Sqrt(Int64)
Get the long value closest to √x.
Declaration
public static long Sqrt(long x)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | x |
Returns
| Type | Description |
|---|---|
| System.Int64 |