_Number#
- class basencode._Number(n: Union[int, float, str, Tuple[Union[int, str]], List[Union[int, str]]], base: int = 10, digits: Optional[List[str]] = None)#
Bases:
objectThe parent class for all
Floats andIntegers- Parameters:
n – The number to be converted to decimal and stored
base – The base in which the number provided is represented (this information is used to convert the number to decimal)
digits – The digits used in the provided representation of the number
- property dec_value: Decimal#
Getter returns the decimal value of the
_Number.
- repr_in_base(base: int, digits: Optional[List[str]] = None, mode: str = 's') Union[str, List[str]]#
Represents the decimal value of the instance of
_Numberin the base provided.- Parameters:
base – The base to represent the
_Number’s decimal value indigits – The digits to use in the representation; these are also set as the default digits (for this object) for the base provided.
mode – Whether to return the representation as a string or a list
- Returns:
The representation of the
_Number’s decimal value in the base provided- Return type:
str | list[str]
- repr_in_base64(digits: Optional[List[str]] = None, mode: str = 's') Union[str, List[str]]#
Uses
repr_in_baseto convert the_Numberto base 64.- Parameters:
digits – The digits to use in the representation
mode – Whether to return the representation as a string or a list
- Returns:
The base 64 representation of the
_Number’s decimal value- Return type:
str | list[str]
- repr_in_bin(digits: Optional[List[str]] = None, mode: str = 's') Union[str, List[str]]#
Uses
repr_in_baseto convert the_Numberto binary.- Parameters:
digits – The digits to use in the representation
mode – Whether to return the representation as a string or a list
- Returns:
The binary representation of the
_Number’s decimal value- Return type:
str | list[str]
- repr_in_dec(digits: Optional[List[str]] = None, mode: str = 's') Union[str, List[str]]#
Uses
repr_in_baseto convert the_Numberto decimal.- Parameters:
digits – The digits to use in the representation
mode – Whether to return the representation as a string or a list
- Returns:
The decimal representation of the
_Number’s decimal value- Return type:
str | list[str]
- repr_in_hex(digits: Optional[List[str]] = None, mode: str = 's') Union[str, List[str]]#
Uses
repr_in_baseto convert the_Numberto hexadecimal.- Parameters:
digits – The digits to use in the representation
mode – Whether to return the representation as a string or a list
- Returns:
The hexadecimal representation of the
_Number’s decimal value- Return type:
str | list[str]
- repr_in_octal(digits: Optional[List[str]] = None, mode: str = 's') Union[str, List[str]]#
Uses
repr_in_baseto convert the_Numberto octal.- Parameters:
digits – The digits to use in the representation
mode – Whether to return the representation as a string or a list
- Returns:
The octal representation of the
_Number’s decimal value- Return type:
str | list[str]