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