Table Of Contents

Previous topic

Getting started

Next topic


This Page


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

Leading zeros matter

T3Number conversions

Conversions from T3Numbers

Conversion Type
int(x) int
x.number() int ( same as int(x) )
x.digits() str
x.bytes() array(‘b’, ...)

Operators on T3Numbers

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  

Methods of T3Numbers

class T3Number
__init__(obj, base = 16)
  • obj – object which represents a number.
  • base – the base or radix of the number. The default base is 16.

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:

  • int, long

    Arbitrary int or long values are allowed.

  • str, unicode

    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

    array objects with type code ‘b’ and ‘H’ are allowed.

  • T3Number

    base conversion

find(sub, start = 0, end = None)
classmethod name(signature)