Int32
Utilities for working with the Int32 type.
Edit on GitHubAdded in 0.2.0
No other changes yet.
from "int32" include Int32
1l
-1l
Functions and constants included in the Int32 module.
Added in 0.2.0
No other changes yet.
fromNumber : (number: Number) => Int32
Converts a Number to an Int32.
Parameters:
| param | type | description |
|---|---|---|
number | Number | The value to convert |
number: The value to convertReturns:
| type | description |
|---|---|
Int32 | The Number represented as an Int32 |
Int32: The Number represented as an Int32Added in 0.2.0
No other changes yet.
toNumber : (value: Int32) => Number
Converts an Int32 to a Number.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to convert |
value: The value to convertReturns:
| type | description |
|---|---|
Number | The Int32 represented as a Number |
Number: The Int32 represented as a NumberAdded in 0.6.0
No other changes yet.
fromUint32 : (number: Uint32) => Int32
Converts a Uint32 to an Int32.
Parameters:
| param | type | description |
|---|---|---|
number | Uint32 | The value to convert |
number: The value to convertReturns:
| type | description |
|---|---|
Int32 | The Uint32 represented as an Int32 |
Int32: The Uint32 represented as an Int32Examples:
Int32.fromUint32(1ul) == 1l
Added in 0.2.0
No other changes yet.
incr : (value: Int32) => Int32
Increments the value by one.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to increment |
value: The value to incrementReturns:
| type | description |
|---|---|
Int32 | The incremented value |
Int32: The incremented valueExamples:
Int32.incr(1l) == 2l
Int32.incr(-2l) == -1l
Added in 0.2.0
No other changes yet.
decr : (value: Int32) => Int32
Decrements the value by one.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to decrement |
value: The value to decrementReturns:
| type | description |
|---|---|
Int32 | The decremented value |
Int32: The decremented valueExamples:
Int32.decr(2l) == 1l
Int32.decr(0l) == -1l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `add` |
(+) : (x: Int32, y: Int32) => Int32
Computes the sum of its operands.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | The sum of the two operands |
Int32: The sum of the two operandsExamples:
use Int32.{ (+) }
assert 1l + 1l == 2l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `sub` |
(-) : (x: Int32, y: Int32) => Int32
Computes the difference of its operands.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | The difference of the two operands |
Int32: The difference of the two operandsExamples:
use Int32.{ (-) }
assert 2l - 1l == 1l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `mul` |
(*) : (x: Int32, y: Int32) => Int32
Computes the product of its operands.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | The product of the two operands |
Int32: The product of the two operandsExamples:
use Int32.{ (*) }
assert 2l * 2l == 4l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `div` |
(/) : (x: Int32, y: Int32) => Int32
Computes the quotient of its operands using signed division.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | The quotient of its operands |
Int32: The quotient of its operandsExamples:
use Int32.{ (/) }
assert 8l / 2l == 4l
Added in 0.2.0
No other changes yet.
rem : (x: Int32, y: Int32) => Int32
Computes the remainder of the division of its operands using signed division.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | The remainder of its operands |
Int32: The remainder of its operandsExamples:
Int32.rem(8l, 3l) == 2l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `mod` |
(%) : (x: Int32, y: Int32) => Int32
Computes the remainder of the division of the first operand by the second. The result will have the sign of the second operand.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | The modulus of its operands |
Int32: The modulus of its operandsThrows:
ModuloByZero
- When
yis zero
Examples:
use Int32.{ (%) }
assert -5l % 3l == 1l
Added in 0.4.0
No other changes yet.
rotl : (value: Int32, amount: Int32) => Int32
Rotates the bits of the value left by the given number of bits.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to rotate |
amount | Int32 | The number of bits to rotate by |
value: The value to rotateamount: The number of bits to rotate byReturns:
| type | description |
|---|---|
Int32 | The rotated value |
Int32: The rotated valueExamples:
Int32.rotl(1l, 1l) == 2l
Int32.rotl(1l, 2l) == 4l
Added in 0.4.0
No other changes yet.
rotr : (value: Int32, amount: Int32) => Int32
Rotates the bits of the value right by the given number of bits.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to rotate |
amount | Int32 | The number of bits to rotate by |
value: The value to rotateamount: The number of bits to rotate byReturns:
| type | description |
|---|---|
Int32 | The rotated value |
Int32: The rotated valueExamples:
Int32.rotr(2l, 1l) == 1l
Int32.rotr(4l, 2l) == 1l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `shl` |
(<<) : (value: Int32, amount: Int32) => Int32
Shifts the bits of the value left by the given number of bits.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to shift |
amount | Int32 | The number of bits to shift by |
value: The value to shiftamount: The number of bits to shift byReturns:
| type | description |
|---|---|
Int32 | The shifted value |
Int32: The shifted valueExamples:
use Int32.{ (<<) }
assert (5l << 1l) == 10l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `shr` |
(>>) : (value: Int32, amount: Int32) => Int32
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to shift |
amount | Int32 | The amount to shift by |
value: The value to shiftamount: The amount to shift byReturns:
| type | description |
|---|---|
Int32 | The shifted value |
Int32: The shifted valueExamples:
use Int32.{ (>>) }
assert (5l >> 1l) == 2l
Added in 0.6.0
| version | changes |
|---|---|
0.4.0 | Originally named `eq` |
(==) : (x: Int32, y: Int32) => Bool
Checks if the first value is equal to the second value.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first value |
y | Int32 | The second value |
x: The first valuey: The second valueReturns:
| type | description |
|---|---|
Bool | true if the first value is equal to the second value or false otherwise |
Bool: true if the first value is equal to the second value or false otherwiseExamples:
use Int32.{ (==) }
assert 1l == 1l
Added in 0.6.0
| version | changes |
|---|---|
0.4.0 | Originally named `ne` |
(!=) : (x: Int32, y: Int32) => Bool
Checks if the first value is not equal to the second value.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first value |
y | Int32 | The second value |
x: The first valuey: The second valueReturns:
| type | description |
|---|---|
Bool | true if the first value is not equal to the second value or false otherwise |
Bool: true if the first value is not equal to the second value or false otherwiseExamples:
use Int32.{ (!=) }
assert 1l != 2l
Added in 0.4.0
No other changes yet.
eqz : (value: Int32) => Bool
Checks if the given value is equal to zero.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to inspect |
value: The value to inspectReturns:
| type | description |
|---|---|
Bool | true if the first value is equal to zero or false otherwise |
Bool: true if the first value is equal to zero or false otherwiseExamples:
Int32.eqz(0l) == true
Int32.eqz(1l) == false
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `lt` |
(<) : (x: Int32, y: Int32) => Bool
Checks if the first value is less than the second value.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first value |
y | Int32 | The second value |
x: The first valuey: The second valueReturns:
| type | description |
|---|---|
Bool | true if the first value is less than the second value or false otherwise |
Bool: true if the first value is less than the second value or false otherwiseExamples:
use Int32.{ (<) }
assert 1l < 2l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `gt` |
(>) : (x: Int32, y: Int32) => Bool
Checks if the first value is greater than the second value.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first value |
y | Int32 | The second value |
x: The first valuey: The second valueReturns:
| type | description |
|---|---|
Bool | true if the first value is greater than the second value or false otherwise |
Bool: true if the first value is greater than the second value or false otherwiseExamples:
use Int32.{ (>) }
assert 2l > 1l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `lte` |
(<=) : (x: Int32, y: Int32) => Bool
Checks if the first value is less than or equal to the second value.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first value |
y | Int32 | The second value |
x: The first valuey: The second valueReturns:
| type | description |
|---|---|
Bool | true if the first value is less than or equal to the second value or false otherwise |
Bool: true if the first value is less than or equal to the second value or false otherwiseExamples:
use Int32.{ (<=) }
assert 1l <= 2l
use Int32.{ (<=) }
assert 1l <= 1l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `gte` |
(>=) : (x: Int32, y: Int32) => Bool
Checks if the first value is greater than or equal to the second value.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first value |
y | Int32 | The second value |
x: The first valuey: The second valueReturns:
| type | description |
|---|---|
Bool | true if the first value is greater than or equal to the second value or false otherwise |
Bool: true if the first value is greater than or equal to the second value or false otherwiseExamples:
use Int32.{ (>=) }
assert 2l >= 1l
use Int32.{ (>=) }
assert 1l >= 1l
Added in 0.2.0
No other changes yet.
lnot : (value: Int32) => Int32
Computes the bitwise NOT of the given value.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The given value |
value: The given valueReturns:
| type | description |
|---|---|
Int32 | Containing the inverted bits of the given value |
Int32: Containing the inverted bits of the given valueExamples:
Int32.lnot(-5l) == 4l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `land` |
(&) : (x: Int32, y: Int32) => Int32
Computes the bitwise AND (&) on the given operands.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | Containing a 1 in each bit position for which the corresponding bits of both operands are 1 |
Int32: Containing a 1 in each bit position for which the corresponding bits of both operands are 1Examples:
use Int32.{ (&) }
assert (3l & 4l) == 0l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `lor` |
(|) : (x: Int32, y: Int32) => Int32
Computes the bitwise OR (|) on the given operands.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | Containing a 1 in each bit position for which the corresponding bits of either or both operands are 1 |
Int32: Containing a 1 in each bit position for which the corresponding bits of either or both operands are 1Examples:
use Int32.{ (|) }
assert (3l | 4l) == 7l
Added in 0.6.0
| version | changes |
|---|---|
0.2.0 | Originally named `lxor` |
(^) : (x: Int32, y: Int32) => Int32
Computes the bitwise XOR (^) on the given operands.
Parameters:
| param | type | description |
|---|---|---|
x | Int32 | The first operand |
y | Int32 | The second operand |
x: The first operandy: The second operandReturns:
| type | description |
|---|---|
Int32 | Containing a 1 in each bit position for which the corresponding bits of either but not both operands are 1 |
Int32: Containing a 1 in each bit position for which the corresponding bits of either but not both operands are 1Examples:
use Int32.{ (^) }
assert (3l ^ 5l) == 6l
Added in 0.4.0
No other changes yet.
clz : (value: Int32) => Int32
Counts the number of leading zero bits in the value.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to inspect |
value: The value to inspectReturns:
| type | description |
|---|---|
Int32 | The amount of leading zeros |
Int32: The amount of leading zerosExamples:
Int32.clz(1l) == 31l
Int32.clz(4l) == 29l
Added in 0.4.0
No other changes yet.
ctz : (value: Int32) => Int32
Counts the number of trailing zero bits in the value.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to inspect |
value: The value to inspectReturns:
| type | description |
|---|---|
Int32 | The amount of trailing zeros |
Int32: The amount of trailing zerosExamples:
Int32.ctz(1l) == 0l
Int32.ctz(4l) == 2l
Added in 0.4.0
No other changes yet.
popcnt : (value: Int32) => Int32
Counts the number of bits set to 1 in the value, also known as a population count.
Parameters:
| param | type | description |
|---|---|---|
value | Int32 | The value to inspect |
value: The value to inspectReturns:
| type | description |
|---|---|
Int32 | The amount of 1-bits in its operand |
Int32: The amount of 1-bits in its operandExamples:
Int32.popcnt(1l) == 1l
Int32.popcnt(3l) == 2l
Added in 0.6.0
No other changes yet.
(**) : (base: Int32, power: Int32) => Int32
Computes the exponentiation of the given base and power.
Parameters:
| param | type | description |
|---|---|---|
base | Int32 | The base number |
power | Int32 | The exponent number |
base: The base numberpower: The exponent numberReturns:
| type | description |
|---|---|
Int32 | The base raised to the given power |
Int32: The base raised to the given powerExamples:
from Int32 use { (**) }
assert 2l ** 3l == 8l