A T3Number is a crossing between an integer and a string. A T3Number supports arithmetic operations like addition and multiplication, bitwise operations such as inversions and shifts but it has also a length, is iterable and allows concatenations.
T3Numbers were designed to represent hexadecimal strings with an arbitrary number of leading zeros. Additionally convenient arithmetics operations should be performed on them wit
Conversion | Type |
---|---|
int(x) | int |
x.number() | int ( same as int(x) ) |
x.digits() | str |
x.bytes() | array(‘b’, ...) |
The operators used on T3Numbers
Operation | Result | Notes |
---|---|---|
x + y | sum of x and y | |
x - y | difference of x and y | |
x * y | product of x and y | |
x / y | quotient of x and y | |
x // y | concatenation of x and y | (1) |
-x | x negated | |
~x | x bitwise inverted | |
x | y | bitwise or of x and y | |
x ^ y | bitwise xor of x and y | |
x & y | bitwise and of x and y | |
x << n | x shifted left by n bits | |
x >> n | x shifted right by n bits | (2) |
len(x) | length of x as the number of digits in the given radix | (4) |
int(x) | x converted to integer |
Parameters: |
|
---|
The base value value must be in {2..16}.
The obj parameter should have one of the following types:
- int
- long
- str
- unicode
- array
- T3Number
- T3Value
Values of the listed types will be treated as follows:
Arbitrary int or long values are allowed.
Hexadecimal characters i.e. chars in the set {‘0’..‘9’ ‘a’..’f’ ‘A’..’F’} will be identified as numeral characters. All other characters will be ignored.
A numerical character c must fit the base i.e. the following inequality holds
c < base
Otherwise a ValueError is raised.
array objects with type code ‘b’ and ‘H’ are allowed.
base conversion