radices — Arithmetic for any positional notation systems

kanon.units.radices Module

In this module we define RadixBase and BasedReal. RadixBase is the basis of the way we work with different radices. BasedReal are a class of Real numbers with a 1-1 relation with a RadixBase.

>>> from kanon.units import RadixBase, radix_registry
>>> example_base = RadixBase([20, 5, 18], [24, 60], "example_base", [" ","u ","sep "])
>>> number = radix_registry["ExampleBase"]((8, 12, 3, 1), (23, 31))
>>> number
08 12u 3sep 01 ; 23,31
>>> float(number)
15535.979861111111

Classes

RadixBase(left, right, name, integer_separators)

A class representing a numeral system.

BasedReal(*args[, remainder, sign])

Abstract class allowing to represent a value in a specific RadixBase.

Variables

radix_registry

Registry containing all instanciated BasedReal classes.

Class Inheritance Diagram

Inheritance diagram of kanon.units.radices.RadixBase, kanon.units.radices.BasedReal