dartora

BaseRadix

BaseRadix represents a number in an arbitrary radix (base). It stores three pieces of information:

Construction

To create a BaseRadix instance, use the private constructor or the static factory methods:

const BaseRadix({ required int radix, required String code, required double number });

static BaseRadix toBase(double val, int radix, [int resolution = 0])
static BaseRadix fromBase(String val, int radix, [int resolution = 10000])

Arithmetic

BaseRadix overloads common arithmetic operators by delegating to double arithmetic and then re‑encoding the result in the same base:

Notes

BaseRadix.digits is a static list of allowable digit characters. toBase and fromBase use this list when converting between numeric and string representations.

BaseRadix is immutable; all arithmetic returns new instances. It is useful for representing and computing with numbers in non‑decimal bases while retaining the original base representation.