Skip to main content

cast_unsigned

No overview available.

def cast_unsigned(
value: int,
bit_length: int
) - > int

Converts a signed integer to its unsigned representation based on a specified bit length. This is typically used to simulate hardware register behavior or to prepare values for low-level binary protocols.

Parameters

NameTypeDescription
valueintThe signed integer value to be converted.
bit_lengthintThe number of bits used to represent the integer, which determines the wrap-around threshold for the conversion.

Returns

TypeDescription
intThe unsigned integer value resulting from the bitwise conversion.