v0.4.0

Integers v0.1.0

Source
The signed and unsigned integer types from 8 to 512 bits and the pointer-sized int and uint, with their width and limit constants. The built-in byte is uint8 and shares its constants.

int

extend int

A target pointer-sized signed integer.

Source

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.

NameTypeDescription
otherintthe value to add

Returns: the sum, or none when it lies outside the range of int

Source

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.

NameTypeDescription
otherintthe value to subtract

Returns: the difference, or none when it lies outside the range of int

Source

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.

NameTypeDescription
otherintthe value to multiply by

Returns: the product, or none when it lies outside the range of int

Source

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.

NameTypeDescription
otherintthe value to add

Returns: the sum, or the limit of int it ran past

Source

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.

NameTypeDescription
otherintthe value to subtract

Returns: the difference, or the limit of int it ran past

Source

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.

NameTypeDescription
otherintthe value to multiply by

Returns: the product, or the limit of int it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = sizeof(int) * 8u;

The target representation width in bits.

Source

Bytes

pub const Bytes: uint = sizeof(int);

The target representation size in bytes.

Source

Min

pub const Min: int = -(((~0u) >> 1u) as int) - 1;

The smallest representable value.

Source

Max

pub const Max: int = ((~0u) >> 1u) as int;

The largest representable value.

Source

int8

extend int8

A signed integer in 8 bits, two's complement.

Source

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.

NameTypeDescription
otherint8the value to add

Returns: the sum, or none when it lies outside the range of int8

Source

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.

NameTypeDescription
otherint8the value to subtract

Returns: the difference, or none when it lies outside the range of int8

Source

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.

NameTypeDescription
otherint8the value to multiply by

Returns: the product, or none when it lies outside the range of int8

Source

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.

NameTypeDescription
otherint8the value to add

Returns: the sum, or the limit of int8 it ran past

Source

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.

NameTypeDescription
otherint8the value to subtract

Returns: the difference, or the limit of int8 it ran past

Source

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.

NameTypeDescription
otherint8the value to multiply by

Returns: the product, or the limit of int8 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 8;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 1;

The number of bytes in the representation.

Source

Min

pub const Min: int8 = -128;

The smallest representable value.

Source

Max

pub const Max: int8 = 127;

The largest representable value.

Source

int16

extend int16

A signed integer in 16 bits, two's complement.

Source

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.

NameTypeDescription
otherint16the value to add

Returns: the sum, or none when it lies outside the range of int16

Source

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.

NameTypeDescription
otherint16the value to subtract

Returns: the difference, or none when it lies outside the range of int16

Source

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.

NameTypeDescription
otherint16the value to multiply by

Returns: the product, or none when it lies outside the range of int16

Source

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.

NameTypeDescription
otherint16the value to add

Returns: the sum, or the limit of int16 it ran past

Source

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.

NameTypeDescription
otherint16the value to subtract

Returns: the difference, or the limit of int16 it ran past

Source

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.

NameTypeDescription
otherint16the value to multiply by

Returns: the product, or the limit of int16 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 16;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 2;

The number of bytes in the representation.

Source

Min

pub const Min: int16 = -32768;

The smallest representable value.

Source

Max

pub const Max: int16 = 32767;

The largest representable value.

Source

int32

extend int32

A signed integer in 32 bits, two's complement.

Source

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.

NameTypeDescription
otherint32the value to add

Returns: the sum, or none when it lies outside the range of int32

Source

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.

NameTypeDescription
otherint32the value to subtract

Returns: the difference, or none when it lies outside the range of int32

Source

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.

NameTypeDescription
otherint32the value to multiply by

Returns: the product, or none when it lies outside the range of int32

Source

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.

NameTypeDescription
otherint32the value to add

Returns: the sum, or the limit of int32 it ran past

Source

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.

NameTypeDescription
otherint32the value to subtract

Returns: the difference, or the limit of int32 it ran past

Source

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.

NameTypeDescription
otherint32the value to multiply by

Returns: the product, or the limit of int32 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 32;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 4;

The number of bytes in the representation.

Source

Min

pub const Min: int32 = -2147483648;

The smallest representable value.

Source

Max

pub const Max: int32 = 2147483647;

The largest representable value.

Source

int64

extend int64

A signed integer in 64 bits, two's complement.

Source

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.

NameTypeDescription
otherint64the value to add

Returns: the sum, or none when it lies outside the range of int64

Source

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.

NameTypeDescription
otherint64the value to subtract

Returns: the difference, or none when it lies outside the range of int64

Source

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.

NameTypeDescription
otherint64the value to multiply by

Returns: the product, or none when it lies outside the range of int64

Source

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.

NameTypeDescription
otherint64the value to add

Returns: the sum, or the limit of int64 it ran past

Source

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.

NameTypeDescription
otherint64the value to subtract

Returns: the difference, or the limit of int64 it ran past

Source

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.

NameTypeDescription
otherint64the value to multiply by

Returns: the product, or the limit of int64 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 64;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 8;

The number of bytes in the representation.

Source

Min

pub const Min: int64 = -9223372036854775808;

The smallest representable value.

Source

Max

pub const Max: int64 = 9223372036854775807;

The largest representable value.

Source

int128

extend int128

A signed integer in 128 bits, two's complement.

Source

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.

NameTypeDescription
otherint128the value to add

Returns: the sum, or none when it lies outside the range of int128

Source

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.

NameTypeDescription
otherint128the value to subtract

Returns: the difference, or none when it lies outside the range of int128

Source

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.

NameTypeDescription
otherint128the value to multiply by

Returns: the product, or none when it lies outside the range of int128

Source

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.

NameTypeDescription
otherint128the value to add

Returns: the sum, or the limit of int128 it ran past

Source

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.

NameTypeDescription
otherint128the value to subtract

Returns: the difference, or the limit of int128 it ran past

Source

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.

NameTypeDescription
otherint128the value to multiply by

Returns: the product, or the limit of int128 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 128u;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 16u;

The number of bytes in the representation.

Source

Min

pub const Min: int128 = -170141183460469231731687303715884105728i128;

The smallest representable value.

Source

Max

pub const Max: int128 = 170141183460469231731687303715884105727i128;

The largest representable value.

Source

int256

extend int256

A signed integer in 256 bits, two's complement.

Source

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.

NameTypeDescription
otherint256the value to add

Returns: the sum, or none when it lies outside the range of int256

Source

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.

NameTypeDescription
otherint256the value to subtract

Returns: the difference, or none when it lies outside the range of int256

Source

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.

NameTypeDescription
otherint256the value to multiply by

Returns: the product, or none when it lies outside the range of int256

Source

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.

NameTypeDescription
otherint256the value to add

Returns: the sum, or the limit of int256 it ran past

Source

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.

NameTypeDescription
otherint256the value to subtract

Returns: the difference, or the limit of int256 it ran past

Source

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.

NameTypeDescription
otherint256the value to multiply by

Returns: the product, or the limit of int256 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 256u;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 32u;

The number of bytes in the representation.

Source

Min

pub const Min: int256 = -57896044618658097711785492504343953926634992332820282019728792003956564819968i256;

The smallest representable value.

Source

Max

pub const Max: int256 = 57896044618658097711785492504343953926634992332820282019728792003956564819967i256;

The largest representable value.

Source

int512

extend int512

A signed integer in 512 bits, two's complement.

Source

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.

NameTypeDescription
otherint512the value to add

Returns: the sum, or none when it lies outside the range of int512

Source

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.

NameTypeDescription
otherint512the value to subtract

Returns: the difference, or none when it lies outside the range of int512

Source

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.

NameTypeDescription
otherint512the value to multiply by

Returns: the product, or none when it lies outside the range of int512

Source

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.

NameTypeDescription
otherint512the value to add

Returns: the sum, or the limit of int512 it ran past

Source

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.

NameTypeDescription
otherint512the value to subtract

Returns: the difference, or the limit of int512 it ran past

Source

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.

NameTypeDescription
otherint512the value to multiply by

Returns: the product, or the limit of int512 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 512u;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 64u;

The number of bytes in the representation.

Source

Min

pub const Min: int512 = …;

The smallest representable value.

Source

Max

pub const Max: int512 = …;

The largest representable value.

Source

uint

extend uint

A target pointer-sized unsigned integer.

Source

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.

NameTypeDescription
otheruintthe value to add

Returns: the sum, or none when it lies outside the range of uint

Source

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.

NameTypeDescription
otheruintthe value to subtract

Returns: the difference, or none when it lies outside the range of uint

Source

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.

NameTypeDescription
otheruintthe value to multiply by

Returns: the product, or none when it lies outside the range of uint

Source

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.

NameTypeDescription
otheruintthe value to add

Returns: the sum, or the limit of uint it ran past

Source

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.

NameTypeDescription
otheruintthe value to subtract

Returns: the difference, or the limit of uint it ran past

Source

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.

NameTypeDescription
otheruintthe value to multiply by

Returns: the product, or the limit of uint it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = sizeof(uint) * 8u;

The target representation width in bits.

Source

Bytes

pub const Bytes: uint = sizeof(uint);

The target representation size in bytes.

Source

Min

pub const Min: uint = 0u;

The smallest representable value.

Source

Max

pub const Max: uint = ~0u;

The largest representable value.

Source

uint8

extend uint8

An unsigned integer in 8 bits.

Source

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.

NameTypeDescription
otheruint8the value to add

Returns: the sum, or none when it lies outside the range of uint8

Source

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.

NameTypeDescription
otheruint8the value to subtract

Returns: the difference, or none when it lies outside the range of uint8

Source

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.

NameTypeDescription
otheruint8the value to multiply by

Returns: the product, or none when it lies outside the range of uint8

Source

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.

NameTypeDescription
otheruint8the value to add

Returns: the sum, or the limit of uint8 it ran past

Source

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.

NameTypeDescription
otheruint8the value to subtract

Returns: the difference, or the limit of uint8 it ran past

Source

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.

NameTypeDescription
otheruint8the value to multiply by

Returns: the product, or the limit of uint8 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 8;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 1;

The number of bytes in the representation.

Source

Min

pub const Min: uint8 = 0;

The smallest representable value.

Source

Max

pub const Max: uint8 = 255;

The largest representable value.

Source

uint16

extend uint16

An unsigned integer in 16 bits.

Source

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.

NameTypeDescription
otheruint16the value to add

Returns: the sum, or none when it lies outside the range of uint16

Source

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.

NameTypeDescription
otheruint16the value to subtract

Returns: the difference, or none when it lies outside the range of uint16

Source

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.

NameTypeDescription
otheruint16the value to multiply by

Returns: the product, or none when it lies outside the range of uint16

Source

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.

NameTypeDescription
otheruint16the value to add

Returns: the sum, or the limit of uint16 it ran past

Source

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.

NameTypeDescription
otheruint16the value to subtract

Returns: the difference, or the limit of uint16 it ran past

Source

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.

NameTypeDescription
otheruint16the value to multiply by

Returns: the product, or the limit of uint16 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 16;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 2;

The number of bytes in the representation.

Source

Min

pub const Min: uint16 = 0;

The smallest representable value.

Source

Max

pub const Max: uint16 = 65535;

The largest representable value.

Source

uint32

extend uint32

An unsigned integer in 32 bits.

Source

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.

NameTypeDescription
otheruint32the value to add

Returns: the sum, or none when it lies outside the range of uint32

Source

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.

NameTypeDescription
otheruint32the value to subtract

Returns: the difference, or none when it lies outside the range of uint32

Source

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.

NameTypeDescription
otheruint32the value to multiply by

Returns: the product, or none when it lies outside the range of uint32

Source

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.

NameTypeDescription
otheruint32the value to add

Returns: the sum, or the limit of uint32 it ran past

Source

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.

NameTypeDescription
otheruint32the value to subtract

Returns: the difference, or the limit of uint32 it ran past

Source

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.

NameTypeDescription
otheruint32the value to multiply by

Returns: the product, or the limit of uint32 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 32;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 4;

The number of bytes in the representation.

Source

Min

pub const Min: uint32 = 0;

The smallest representable value.

Source

Max

pub const Max: uint32 = 4294967295;

The largest representable value.

Source

uint64

extend uint64

An unsigned integer in 64 bits.

Source

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.

NameTypeDescription
otheruint64the value to add

Returns: the sum, or none when it lies outside the range of uint64

Source

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.

NameTypeDescription
otheruint64the value to subtract

Returns: the difference, or none when it lies outside the range of uint64

Source

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.

NameTypeDescription
otheruint64the value to multiply by

Returns: the product, or none when it lies outside the range of uint64

Source

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.

NameTypeDescription
otheruint64the value to add

Returns: the sum, or the limit of uint64 it ran past

Source

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.

NameTypeDescription
otheruint64the value to subtract

Returns: the difference, or the limit of uint64 it ran past

Source

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.

NameTypeDescription
otheruint64the value to multiply by

Returns: the product, or the limit of uint64 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 64;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 8;

The number of bytes in the representation.

Source

Min

pub const Min: uint64 = 0;

The smallest representable value.

Source

Max

pub const Max: uint64 = 18446744073709551615;

The largest representable value.

Source

uint128

extend uint128

An unsigned integer in 128 bits.

Source

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.

NameTypeDescription
otheruint128the value to add

Returns: the sum, or none when it lies outside the range of uint128

Source

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.

NameTypeDescription
otheruint128the value to subtract

Returns: the difference, or none when it lies outside the range of uint128

Source

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.

NameTypeDescription
otheruint128the value to multiply by

Returns: the product, or none when it lies outside the range of uint128

Source

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.

NameTypeDescription
otheruint128the value to add

Returns: the sum, or the limit of uint128 it ran past

Source

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.

NameTypeDescription
otheruint128the value to subtract

Returns: the difference, or the limit of uint128 it ran past

Source

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.

NameTypeDescription
otheruint128the value to multiply by

Returns: the product, or the limit of uint128 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 128u;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 16u;

The number of bytes in the representation.

Source

Min

pub const Min: uint128 = 0u128;

The smallest representable value.

Source

Max

pub const Max: uint128 = 340282366920938463463374607431768211455u128;

The largest representable value.

Source

uint256

extend uint256

An unsigned integer in 256 bits.

Source

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.

NameTypeDescription
otheruint256the value to add

Returns: the sum, or none when it lies outside the range of uint256

Source

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.

NameTypeDescription
otheruint256the value to subtract

Returns: the difference, or none when it lies outside the range of uint256

Source

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.

NameTypeDescription
otheruint256the value to multiply by

Returns: the product, or none when it lies outside the range of uint256

Source

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.

NameTypeDescription
otheruint256the value to add

Returns: the sum, or the limit of uint256 it ran past

Source

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.

NameTypeDescription
otheruint256the value to subtract

Returns: the difference, or the limit of uint256 it ran past

Source

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.

NameTypeDescription
otheruint256the value to multiply by

Returns: the product, or the limit of uint256 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 256u;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 32u;

The number of bytes in the representation.

Source

Min

pub const Min: uint256 = 0u256;

The smallest representable value.

Source

Max

pub const Max: uint256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935u256;

The largest representable value.

Source

uint512

extend uint512

An unsigned integer in 512 bits.

Source

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.

NameTypeDescription
otheruint512the value to add

Returns: the sum, or none when it lies outside the range of uint512

Source

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.

NameTypeDescription
otheruint512the value to subtract

Returns: the difference, or none when it lies outside the range of uint512

Source

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.

NameTypeDescription
otheruint512the value to multiply by

Returns: the product, or none when it lies outside the range of uint512

Source

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.

NameTypeDescription
otheruint512the value to add

Returns: the sum, or the limit of uint512 it ran past

Source

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.

NameTypeDescription
otheruint512the value to subtract

Returns: the difference, or the limit of uint512 it ran past

Source

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.

NameTypeDescription
otheruint512the value to multiply by

Returns: the product, or the limit of uint512 it ran past

Source

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 parameterDescription
Tthe integer type to convert to

Returns: the low bits of this value as a T

Source

Constants

Bits

pub const Bits: uint = 512u;

The number of bits in the representation.

Source

Bytes

pub const Bytes: uint = 64u;

The number of bytes in the representation.

Source

Min

pub const Min: uint512 = 0u512;

The smallest representable value.

Source

Max

pub const Max: uint512 = …;

The largest representable value.

Source