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