gdDocumentation0.8.0

API reference

GD.math.bits

Integer math entry for uint64 bit counts, rotations, reversals, and operations with carry.

Methods

len64

len64(x: int) -> int

Operate on the bit counts and layout of uint64 values.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

leading_zeros64

leading_zeros64(x: int) -> int

Count leading zero bits.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

trailing_zeros64

trailing_zeros64(x: int) -> int

Count trailing zero bits.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

ones_count64

ones_count64(x: int) -> int

Count set bits.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

rotate_left64

rotate_left64(x: int, k: int) -> int

Rotate left within 64 bits, accepting negative shifts.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.
kintRequiredBit rotation amount; negative values rotate in the opposite direction.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

reverse64

reverse64(x: int) -> int

Reverse all 64 bits.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

reverse_bytes64

reverse_bytes64(x: int) -> int

Reverse the order of eight bytes.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

add64

add64(x: int, y: int, carry: int) -> Array

Return uint64 arithmetic with carry or borrow as two-element arrays.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.
yintRequiredSecond 64-bit word for the arithmetic operation.
carryintRequiredIncoming carry bit, either 0 or 1.

Return value

Array

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

sub64

sub64(x: int, y: int, borrow: int) -> Array

Subtract uint64 values and return borrow.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.
yintRequiredSecond 64-bit word for the arithmetic operation.
borrowintRequiredIncoming borrow bit, either 0 or 1.

Return value

Array

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

mul64

mul64(x: int, y: int) -> Array

Return the high and low halves of a uint64 product.

Parameters

NameTypeDefaultDescription
xintRequired64-bit word represented by a script integer.
yintRequiredSecond 64-bit word for the arithmetic operation.

Return value

Array

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.