Integers v0.1.0
int
extend int
A target pointer-sized signed integer.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int) -> int?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int | the value to add |
Returns: the sum, or none when it lies outside the range of int
CheckedSub
pub func CheckedSub(&self, other: int) -> int?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int | the value to subtract |
Returns: the difference, or none when it lies outside the range of int
CheckedMul
pub func CheckedMul(&self, other: int) -> int?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int | the value to multiply by |
Returns: the product, or none when it lies outside the range of int
SaturatingAdd
pub func SaturatingAdd(&self, other: int) -> int
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int | the value to add |
Returns: the sum, or the limit of int it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int) -> int
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int | the value to subtract |
Returns: the difference, or the limit of int it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int) -> int
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int | the value to multiply by |
Returns: the product, or the limit of int it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = sizeof(int) * 8u;
The target representation width in bits.
Bytes
pub const Bytes: uint = sizeof(int);
The target representation size in bytes.
Min
pub const Min: int = -(((~0u) >> 1u) as int) - 1;
The smallest representable value.
Max
pub const Max: int = ((~0u) >> 1u) as int;
The largest representable value.
int8
extend int8
A signed integer in 8 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int8) -> int8?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int8 | the value to add |
Returns: the sum, or none when it lies outside the range of int8
CheckedSub
pub func CheckedSub(&self, other: int8) -> int8?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int8 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int8
CheckedMul
pub func CheckedMul(&self, other: int8) -> int8?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int8 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int8
SaturatingAdd
pub func SaturatingAdd(&self, other: int8) -> int8
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int8 | the value to add |
Returns: the sum, or the limit of int8 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int8) -> int8
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int8 | the value to subtract |
Returns: the difference, or the limit of int8 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int8) -> int8
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int8 | the value to multiply by |
Returns: the product, or the limit of int8 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int8, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 8;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 1;
The number of bytes in the representation.
Min
pub const Min: int8 = -128;
The smallest representable value.
Max
pub const Max: int8 = 127;
The largest representable value.
int16
extend int16
A signed integer in 16 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int16) -> int16?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int16 | the value to add |
Returns: the sum, or none when it lies outside the range of int16
CheckedSub
pub func CheckedSub(&self, other: int16) -> int16?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int16 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int16
CheckedMul
pub func CheckedMul(&self, other: int16) -> int16?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int16 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int16
SaturatingAdd
pub func SaturatingAdd(&self, other: int16) -> int16
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int16 | the value to add |
Returns: the sum, or the limit of int16 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int16) -> int16
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int16 | the value to subtract |
Returns: the difference, or the limit of int16 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int16) -> int16
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int16 | the value to multiply by |
Returns: the product, or the limit of int16 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int16, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 16;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 2;
The number of bytes in the representation.
Min
pub const Min: int16 = -32768;
The smallest representable value.
Max
pub const Max: int16 = 32767;
The largest representable value.
int32
extend int32
A signed integer in 32 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int32) -> int32?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int32 | the value to add |
Returns: the sum, or none when it lies outside the range of int32
CheckedSub
pub func CheckedSub(&self, other: int32) -> int32?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int32 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int32
CheckedMul
pub func CheckedMul(&self, other: int32) -> int32?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int32 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int32
SaturatingAdd
pub func SaturatingAdd(&self, other: int32) -> int32
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int32 | the value to add |
Returns: the sum, or the limit of int32 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int32) -> int32
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int32 | the value to subtract |
Returns: the difference, or the limit of int32 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int32) -> int32
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int32 | the value to multiply by |
Returns: the product, or the limit of int32 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int32, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 32;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 4;
The number of bytes in the representation.
Min
pub const Min: int32 = -2147483648;
The smallest representable value.
Max
pub const Max: int32 = 2147483647;
The largest representable value.
int64
extend int64
A signed integer in 64 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int64) -> int64?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int64 | the value to add |
Returns: the sum, or none when it lies outside the range of int64
CheckedSub
pub func CheckedSub(&self, other: int64) -> int64?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int64 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int64
CheckedMul
pub func CheckedMul(&self, other: int64) -> int64?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int64 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int64
SaturatingAdd
pub func SaturatingAdd(&self, other: int64) -> int64
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int64 | the value to add |
Returns: the sum, or the limit of int64 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int64) -> int64
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int64 | the value to subtract |
Returns: the difference, or the limit of int64 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int64) -> int64
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int64 | the value to multiply by |
Returns: the product, or the limit of int64 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int64, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 64;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 8;
The number of bytes in the representation.
Min
pub const Min: int64 = -9223372036854775808;
The smallest representable value.
Max
pub const Max: int64 = 9223372036854775807;
The largest representable value.
int128
extend int128
A signed integer in 128 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int128) -> int128?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int128 | the value to add |
Returns: the sum, or none when it lies outside the range of int128
CheckedSub
pub func CheckedSub(&self, other: int128) -> int128?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int128 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int128
CheckedMul
pub func CheckedMul(&self, other: int128) -> int128?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int128 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int128
SaturatingAdd
pub func SaturatingAdd(&self, other: int128) -> int128
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int128 | the value to add |
Returns: the sum, or the limit of int128 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int128) -> int128
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int128 | the value to subtract |
Returns: the difference, or the limit of int128 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int128) -> int128
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int128 | the value to multiply by |
Returns: the product, or the limit of int128 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int128, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 128u;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 16u;
The number of bytes in the representation.
Min
pub const Min: int128 = -170141183460469231731687303715884105728i128;
The smallest representable value.
Max
pub const Max: int128 = 170141183460469231731687303715884105727i128;
The largest representable value.
int256
extend int256
A signed integer in 256 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int256) -> int256?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int256 | the value to add |
Returns: the sum, or none when it lies outside the range of int256
CheckedSub
pub func CheckedSub(&self, other: int256) -> int256?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int256 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int256
CheckedMul
pub func CheckedMul(&self, other: int256) -> int256?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int256 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int256
SaturatingAdd
pub func SaturatingAdd(&self, other: int256) -> int256
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int256 | the value to add |
Returns: the sum, or the limit of int256 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int256) -> int256
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int256 | the value to subtract |
Returns: the difference, or the limit of int256 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int256) -> int256
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int256 | the value to multiply by |
Returns: the product, or the limit of int256 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int256, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 256u;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 32u;
The number of bytes in the representation.
Min
pub const Min: int256 = -57896044618658097711785492504343953926634992332820282019728792003956564819968i256;
The smallest representable value.
Max
pub const Max: int256 = 57896044618658097711785492504343953926634992332820282019728792003956564819967i256;
The largest representable value.
int512
extend int512
A signed integer in 512 bits, two's complement.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: int512) -> int512?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | int512 | the value to add |
Returns: the sum, or none when it lies outside the range of int512
CheckedSub
pub func CheckedSub(&self, other: int512) -> int512?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | int512 | the value to subtract |
Returns: the difference, or none when it lies outside the range of int512
CheckedMul
pub func CheckedMul(&self, other: int512) -> int512?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | int512 | the value to multiply by |
Returns: the product, or none when it lies outside the range of int512
SaturatingAdd
pub func SaturatingAdd(&self, other: int512) -> int512
Adds other to this value, clamping a sum that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int512 | the value to add |
Returns: the sum, or the limit of int512 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: int512) -> int512
Subtracts other from this value, clamping a difference that does not fit to whichever limit it ran past.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int512 | the value to subtract |
Returns: the difference, or the limit of int512 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: int512) -> int512
Multiplies this value by other, clamping a product that does not fit to the minimum or the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | int512 | the value to multiply by |
Returns: the product, or the limit of int512 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of int512, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 512u;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 64u;
The number of bytes in the representation.
Min
pub const Min: int512 = …;
The smallest representable value.
Max
pub const Max: int512 = …;
The largest representable value.
uint
extend uint
A target pointer-sized unsigned integer.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint) -> uint?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint | the value to add |
Returns: the sum, or none when it lies outside the range of uint
CheckedSub
pub func CheckedSub(&self, other: uint) -> uint?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint
CheckedMul
pub func CheckedMul(&self, other: uint) -> uint?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint
SaturatingAdd
pub func SaturatingAdd(&self, other: uint) -> uint
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint | the value to add |
Returns: the sum, or the limit of uint it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint) -> uint
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint | the value to subtract |
Returns: the difference, or the limit of uint it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint) -> uint
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint | the value to multiply by |
Returns: the product, or the limit of uint it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = sizeof(uint) * 8u;
The target representation width in bits.
Bytes
pub const Bytes: uint = sizeof(uint);
The target representation size in bytes.
Min
pub const Min: uint = 0u;
The smallest representable value.
Max
pub const Max: uint = ~0u;
The largest representable value.
uint8
extend uint8
An unsigned integer in 8 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint8) -> uint8?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint8 | the value to add |
Returns: the sum, or none when it lies outside the range of uint8
CheckedSub
pub func CheckedSub(&self, other: uint8) -> uint8?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint8 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint8
CheckedMul
pub func CheckedMul(&self, other: uint8) -> uint8?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint8 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint8
SaturatingAdd
pub func SaturatingAdd(&self, other: uint8) -> uint8
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint8 | the value to add |
Returns: the sum, or the limit of uint8 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint8) -> uint8
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint8 | the value to subtract |
Returns: the difference, or the limit of uint8 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint8) -> uint8
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint8 | the value to multiply by |
Returns: the product, or the limit of uint8 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint8, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 8;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 1;
The number of bytes in the representation.
Min
pub const Min: uint8 = 0;
The smallest representable value.
Max
pub const Max: uint8 = 255;
The largest representable value.
uint16
extend uint16
An unsigned integer in 16 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint16) -> uint16?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint16 | the value to add |
Returns: the sum, or none when it lies outside the range of uint16
CheckedSub
pub func CheckedSub(&self, other: uint16) -> uint16?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint16 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint16
CheckedMul
pub func CheckedMul(&self, other: uint16) -> uint16?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint16 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint16
SaturatingAdd
pub func SaturatingAdd(&self, other: uint16) -> uint16
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint16 | the value to add |
Returns: the sum, or the limit of uint16 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint16) -> uint16
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint16 | the value to subtract |
Returns: the difference, or the limit of uint16 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint16) -> uint16
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint16 | the value to multiply by |
Returns: the product, or the limit of uint16 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint16, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 16;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 2;
The number of bytes in the representation.
Min
pub const Min: uint16 = 0;
The smallest representable value.
Max
pub const Max: uint16 = 65535;
The largest representable value.
uint32
extend uint32
An unsigned integer in 32 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint32) -> uint32?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint32 | the value to add |
Returns: the sum, or none when it lies outside the range of uint32
CheckedSub
pub func CheckedSub(&self, other: uint32) -> uint32?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint32 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint32
CheckedMul
pub func CheckedMul(&self, other: uint32) -> uint32?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint32 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint32
SaturatingAdd
pub func SaturatingAdd(&self, other: uint32) -> uint32
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint32 | the value to add |
Returns: the sum, or the limit of uint32 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint32) -> uint32
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint32 | the value to subtract |
Returns: the difference, or the limit of uint32 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint32) -> uint32
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint32 | the value to multiply by |
Returns: the product, or the limit of uint32 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint32, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 32;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 4;
The number of bytes in the representation.
Min
pub const Min: uint32 = 0;
The smallest representable value.
Max
pub const Max: uint32 = 4294967295;
The largest representable value.
uint64
extend uint64
An unsigned integer in 64 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint64) -> uint64?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint64 | the value to add |
Returns: the sum, or none when it lies outside the range of uint64
CheckedSub
pub func CheckedSub(&self, other: uint64) -> uint64?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint64 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint64
CheckedMul
pub func CheckedMul(&self, other: uint64) -> uint64?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint64 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint64
SaturatingAdd
pub func SaturatingAdd(&self, other: uint64) -> uint64
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint64 | the value to add |
Returns: the sum, or the limit of uint64 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint64) -> uint64
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint64 | the value to subtract |
Returns: the difference, or the limit of uint64 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint64) -> uint64
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint64 | the value to multiply by |
Returns: the product, or the limit of uint64 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint64, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 64;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 8;
The number of bytes in the representation.
Min
pub const Min: uint64 = 0;
The smallest representable value.
Max
pub const Max: uint64 = 18446744073709551615;
The largest representable value.
uint128
extend uint128
An unsigned integer in 128 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint128) -> uint128?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint128 | the value to add |
Returns: the sum, or none when it lies outside the range of uint128
CheckedSub
pub func CheckedSub(&self, other: uint128) -> uint128?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint128 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint128
CheckedMul
pub func CheckedMul(&self, other: uint128) -> uint128?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint128 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint128
SaturatingAdd
pub func SaturatingAdd(&self, other: uint128) -> uint128
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint128 | the value to add |
Returns: the sum, or the limit of uint128 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint128) -> uint128
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint128 | the value to subtract |
Returns: the difference, or the limit of uint128 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint128) -> uint128
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint128 | the value to multiply by |
Returns: the product, or the limit of uint128 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint128, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 128u;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 16u;
The number of bytes in the representation.
Min
pub const Min: uint128 = 0u128;
The smallest representable value.
Max
pub const Max: uint128 = 340282366920938463463374607431768211455u128;
The largest representable value.
uint256
extend uint256
An unsigned integer in 256 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint256) -> uint256?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint256 | the value to add |
Returns: the sum, or none when it lies outside the range of uint256
CheckedSub
pub func CheckedSub(&self, other: uint256) -> uint256?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint256 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint256
CheckedMul
pub func CheckedMul(&self, other: uint256) -> uint256?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint256 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint256
SaturatingAdd
pub func SaturatingAdd(&self, other: uint256) -> uint256
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint256 | the value to add |
Returns: the sum, or the limit of uint256 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint256) -> uint256
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint256 | the value to subtract |
Returns: the difference, or the limit of uint256 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint256) -> uint256
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint256 | the value to multiply by |
Returns: the product, or the limit of uint256 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint256, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 256u;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 32u;
The number of bytes in the representation.
Min
pub const Min: uint256 = 0u256;
The smallest representable value.
Max
pub const Max: uint256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935u256;
The largest representable value.
uint512
extend uint512
An unsigned integer in 512 bits.
Methods
CheckedAdd
pub func CheckedAdd(&self, other: uint512) -> uint512?
Adds other to this value, or reports that the sum does not fit.
Never stops the program: where + would, this returns none and the caller decides what an overflow means.
| Name | Type | Description |
|---|---|---|
other | uint512 | the value to add |
Returns: the sum, or none when it lies outside the range of uint512
CheckedSub
pub func CheckedSub(&self, other: uint512) -> uint512?
Subtracts other from this value, or reports that the difference does not fit.
Never stops the program: where - would, this returns none.
| Name | Type | Description |
|---|---|---|
other | uint512 | the value to subtract |
Returns: the difference, or none when it lies outside the range of uint512
CheckedMul
pub func CheckedMul(&self, other: uint512) -> uint512?
Multiplies this value by other, or reports that the product does not fit.
Never stops the program: where * would, this returns none, which is how a size computed from a count is
checked before it is used.
| Name | Type | Description |
|---|---|---|
other | uint512 | the value to multiply by |
Returns: the product, or none when it lies outside the range of uint512
SaturatingAdd
pub func SaturatingAdd(&self, other: uint512) -> uint512
Adds other to this value, clamping a sum that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint512 | the value to add |
Returns: the sum, or the limit of uint512 it ran past
SaturatingSub
pub func SaturatingSub(&self, other: uint512) -> uint512
Subtracts other from this value, clamping a difference that does not fit to zero.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint512 | the value to subtract |
Returns: the difference, or the limit of uint512 it ran past
SaturatingMul
pub func SaturatingMul(&self, other: uint512) -> uint512
Multiplies this value by other, clamping a product that does not fit to the maximum.
Never stops the program.
| Name | Type | Description |
|---|---|---|
other | uint512 | the value to multiply by |
Returns: the product, or the limit of uint512 it ran past
Truncate
pub func Truncate<T>(&self) -> T
The low bits of this value at the width of T, in two's complement, whether or not the value fits.
Where as keeps the value or stops the program, this keeps the bits on purpose, as a hash or an encoder taking
the low byte of a word does. A wider T extends the value by the signedness of uint512, as as does.
| Type parameter | Description |
|---|---|
T | the integer type to convert to |
Returns: the low bits of this value as a T
Constants
Bits
pub const Bits: uint = 512u;
The number of bits in the representation.
Bytes
pub const Bytes: uint = 64u;
The number of bytes in the representation.
Min
pub const Min: uint512 = 0u512;
The smallest representable value.
Max
pub const Max: uint512 = …;
The largest representable value.