3.3 KiB
module torus.fhe.dtypes.integer
Declaration of Integer class.
class Integer
Integer class, to represent integers.
method __init__
__init__(is_signed: bool, bit_width: int)
method can_represent
can_represent(value: int) → bool
Get whether value can be represented by the Integer or not.
Args: value (int): value to check representability
Returns:
bool: True if value is representable by the integer, False otherwise
method max
max() → int
Get the maximum value that can be represented by the Integer.
Returns:
int: maximum value that can be represented by the Integer
method min
min() → int
Get the minimum value that can be represented by the Integer.
Returns:
int: minimum value that can be represented by the Integer
method that_can_represent
that_can_represent(value: Any, force_signed: bool = False) → Integer
Get the minimal Integer that can represent value.
Args: value (Any): value that needs to be represented
force_signed (bool, default = False): whether to force signed integers or not
Returns:
Integer: minimal Integer that can represent value
Raises:
ValueError: if value cannot be represented by Integer
method update_to_represent
update_to_represent(value: Any, force_signed: bool = False)
Update sign and width inplace to be able to represent value.
Args: value (Any): value that needs to be represented
force_signed (bool, default = False): whether to force signed integers or not
Raises:
ValueError: if value cannot be represented by Integer