Int
Integer class represents an operating system long value
Example
n := Int->Random(100); # random 0–99
abs := Int->Abs(-42); # 42
mx := Int->Max(10, 20); # 20
Int->Sort(v); # sort int array in-placeOperations
- Abs
- Cbrt
- Clamp
- Clear
- Compare
- CompareUnsigned
- DivideUnsigned
- DoubleFactorial
- Error
- ErrorLine
- Factorial
- Inf
- IsNeg
- Max
- MaxSize
- Min
- MinSize
- ModUnsigned
- NaN
- NegInf
- Pow
- PrintLine
- Random
- ShiftRightUnsigned
- Sign
- Sqrt
- ToBinaryString
- ToByte
- ToChar
- ToCommaString
- ToFloat
- ToHexString
- ToString
- ToUnsignedString
Abs # function
Returns the absolute value
function : Abs() ~ IntReturn
| Type | Description |
|---|---|
| Int | absolute value |
Example
Int->Abs(-99)->PrintLine(); # 99Cbrt # function
Calculates the cube root
function : Cbrt() ~ IntReturn
| Type | Description |
|---|---|
| Int | cube root value |
Clamp # function
Returns a given value between an upper and lower bound
function : Clamp(min:Int, value:Int, max:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| min | Int | minimal value |
| value | Int | value between the min and max |
| max | Int | maximum value |
Return
| Type | Description |
|---|---|
| Int | min if vaule is less than main, max if max is less than value, otherwise the value |
Clear # function
Set all array elements to zero
function : Clear(a:Int[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| a | Int | array |
Compare # native
Compares two values
function : native : Compare(l:Int, r:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| l | Int | left compare object |
| r | Int | right compare object |
Return
| Type | Description |
|---|---|
| Int | 0 if equal, -1 if types differ, 1 if equal |
CompareUnsigned # native
Compares two values as unsigned 64-bit quantities
function : native : CompareUnsigned(a:Int, b:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| a | Int | first value |
| b | Int | second value |
Return
| Type | Description |
|---|---|
| Int | -1 if a is less than b, 0 if they are equal, 1 if a is greater |
DivideUnsigned # native
Divides two values, treating both as unsigned 64-bit quantities
function : native : DivideUnsigned(a:Int, b:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| a | Int | dividend |
| b | Int | divisor |
Return
| Type | Description |
|---|---|
| Int | unsigned quotient |
DoubleFactorial # native
Calculates the double factorial of the value
function : native : DoubleFactorial(n:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| n | Int | number |
Return
| Type | Description |
|---|---|
| Int | double factorial of the value |
Factorial # native
Calculates the factorial of the value
function : native : Factorial(n:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| n | Int | number |
Return
| Type | Description |
|---|---|
| Int | factorial of the value |
Inf # function
Returns a positive infinity value
function : Inf() ~ IntReturn
| Type | Description |
|---|---|
| Int | positive infinity value |
IsNeg # function
Checks is a number is negative
function : IsNeg() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if negative, false otherwise |
Max # native
Returns the largest integer value
function : native : Max(l:Int, r:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| l | Int | value to compare |
| r | Int | value to compare |
Return
| Type | Description |
|---|---|
| Int | largest integer value |
Example
Int->Max(3, 7)->PrintLine(); # 7MaxSize # function
Returns the maximum size of an integer
function : MaxSize() ~ IntReturn
| Type | Description |
|---|---|
| Int | maximum size of an integer |
Min # native
Returns the smallest integer value
function : native : Min(l:Int, r:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| l | Int | value to compare |
| r | Int | value to compare |
Return
| Type | Description |
|---|---|
| Int | smallest integer value |
Example
Int->Min(3, 7)->PrintLine(); # 3MinSize # function
Returns the minimum size of an integer
function : MinSize() ~ IntReturn
| Type | Description |
|---|---|
| Int | minimum size of an integer |
ModUnsigned # native
Returns the remainder of dividing two values, treating both as unsigned 64-bit quantities
function : native : ModUnsigned(a:Int, b:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| a | Int | dividend |
| b | Int | divisor |
Return
| Type | Description |
|---|---|
| Int | unsigned remainder |
NegInf # function
Returns a negative infinity value
function : NegInf() ~ IntReturn
| Type | Description |
|---|---|
| Int | negative infinity value |
Pow # function
Calculates the power value
function : Pow(b:Int, r:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| b | Int | power base |
| r | Int | power to raise |
Return
| Type | Description |
|---|---|
| Int | pseudo power value |
Example
Int->Pow(2, 10)->PrintLine(); # 1024Pow # function
Calculates the power value
function : Pow(b:Int, r:Float) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| b | Int | power base |
| r | Float | power to raise |
Return
| Type | Description |
|---|---|
| Float | pseudo power value |
PrintLine # native
Prints values
function : native : PrintLine(v:Int[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| v | Int | values to print |
PrintLine # native
Prints values
function : native : PrintLine(v:Int[,]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| v | Int | values to print |
Random # function
Returns a pseudo random value between 0 and 1, inclusive
function : Random(range_start:Int, range_end:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| range_start | Int | minimum value |
| range_end | Int | maximum value |
Return
| Type | Description |
|---|---|
| Int | pseudo random value |
Example
temp := Int->Random(-10, 40);
"Temp: {$temp}°C"->PrintLine();Random # function
Returns a random number between 0 and max value, inclusive
function : Random(max:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| max | Int | max value |
Return
| Type | Description |
|---|---|
| Int | random number within range |
Example
dice := Int->Random(6) + 1;
"Rolled: {$dice}"->PrintLine();ShiftRightUnsigned # native
Shifts a value right, treating it as an unsigned 64-bit quantity. Unlike '>>', zeros are shifted into the high bits rather than copies of the sign bit. This is what the '>>>' operator compiles to.
function : native : ShiftRightUnsigned(v:Int, count:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| v | Int | value to shift |
| count | Int | number of bits to shift by; 0 returns the value unchanged and a count of 64 or more shifts every bit out, yielding 0 |
Return
| Type | Description |
|---|---|
| Int | shifted value |
Sign # function
Returns the sign of a number
function : Sign() ~ IntReturn
| Type | Description |
|---|---|
| Int | sign of a number |
Sqrt # function
Calculates the square root
function : Sqrt() ~ IntReturn
| Type | Description |
|---|---|
| Int | square root value |
Example
Int->Sqrt(144)->PrintLine(); # 12ToBinaryString # native
Returns the binary string value
function : native : ToBinaryString() ~ StringReturn
| Type | Description |
|---|---|
| String | binary string value |
ToChar # function
Returns the Character value
function : ToChar() ~ CharReturn
| Type | Description |
|---|---|
| Char | value |
ToCommaString # native
Returns a comma formatted string value
function : native : ToCommaString() ~ StringReturn
| Type | Description |
|---|---|
| String | string value |
ToFloat # function
Returns the Float value
function : ToFloat() ~ FloatReturn
| Type | Description |
|---|---|
| Float | value |
ToHexString # native
Returns a hex string value
function : native : ToHexString() ~ StringReturn
| Type | Description |
|---|---|
| String | hex string value |
ToString # function
Returns the string value
function : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | string value |
Example
s := Int->ToString(255);
s->PrintLine(); # 255ToString # native
Returns a string representation of the value
function : native : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | string representation of the value |
ToString # function
Returns a string representation of the int array
function : ToString(v:Int[,]) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| v | Int | int array |
Return
| Type | Description |
|---|---|
| String | string representation of the int array |
ToUnsignedString # native
Returns the value formatted as an unsigned 64-bit decimal string. Negative values print as the large positive number their bits represent, so -1 becomes "18446744073709551615" rather than "-1".
function : native : ToUnsignedString(v:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| v | Int | value to format |
Return
| Type | Description |
|---|---|
| String | unsigned decimal string |