A Chrome Extension that visualizes alternative algorithms for integer base conversion using Linear Algebra and Polynomial Taylor Shifts.
Based on the paper "Alternative Algorithms for Integer Base Conversion" by Steve Palmer (2007).
Standard base conversion is typically taught using iterative division (Euclidean division). However, integer representation can also be viewed as a polynomial
This extension implements two matrix-based algorithms to convert numbers between bases without division:
- The Offset Method (Pascal Matrix): Converts bases by "shifting" the polynomial using a Pascal (Binomial) Matrix. This is mathematically equivalent to a Taylor Shift (change of variable) on the polynomial representation.
- The Multiples Method (Substitution): Converts bases when one base is a multiple of the other (e.g., Base 10 to Base 2) using a Diagonal Scaling Matrix.
-
Arbitrary Precision: Powered by
BigInt, this tool can convert integers of arbitrary length (hundreds of digits) without loss of precision. - Step-by-Step Animation: (New in v1.1.0) An interactive overlay that animates the digit normalization process, showing how fractional remainders are swept and carries are propagated.
-
Full Matrix Equation: Display the exact matrix multiplication steps (
$N \times T = R \rightarrow \text{Final}$ ) used to transform the digits. - Batch Processing: Vectorized implementation converts multiple numbers simultaneously using a single matrix operation.
- Round-Trip Testing: Includes a Batch Output field to easily copy results and paste them back into the input for reverse conversion.
- Advanced Base Support: Supports bases from -62 to 62 (including negative bases like Negabinary).
- Dual Algorithms: Automatically detects if the "Multiples Method" can be used (e.g., Base 8 to Base 2), or defaults to the general "Offset Method."
- Clone or download this repository.
- Open Google Chrome and navigate to
chrome://extensions. - Enable Developer Mode (toggle in the top right corner).
- Click Load Unpacked.
- Select the folder containing this repository.
- Input: Enter integers (one per line) into the text box.
-
Config: Select your Source Base and Target Base.
- Use the Swap (⇄) button to quickly flip source and target.
- Note: Bases -1, 0, and 1 are restricted as they do not function as valid positional number systems.
- Convert: Click Convert to see the static results, transformation matrices, and normalization logs for all numbers.
-
Step-by-Step Animation: Click 🎥 Step-by-Step Animation to open an interactive overlay.
- The visualizer shows the full matrix equation:
$N \times T = R \rightarrow \text{Final}$ . - Watch the Phase 1: Fraction Sweep (left-to-right) and Phase 2: Carry Propagation (right-to-left) in real-time.
- The visualizer shows the full matrix equation:
-
Method:
- Offset (Pascal Matrix): Works for any pair of valid bases.
-
Multiples: Only available if
Source % Target == 0(e.g., Base 16 to Base 4).
-
Visualize: Click Convert & Visualize.
- The extension will display the Input Matrix (N).
- It will show the Transformation Matrix (
$T$ or$D$ ). - It will show the Result Matrix (R) before normalization.
- Finally, it displays the normalized digits in the target base.
- Copy Results: Use the Batch Output text area at the bottom to copy all converted numbers at once.
This method relies on the observation that converting from Base
-
Theory: The paper defines a base Pascal Matrix
$P$ with entries$P_{r,c} = \binom{c}{r}$ . The transformation for an offset$e$ is achieved by raising this matrix to the power of$e$ ($P^e$ ). -
Implementation: The code computes the final Transformation Matrix (
$T = P^e$ ) directly using the combined formula:$$T_{r,c} = \binom{c}{r} \cdot e^{c-r}$$ -
Operation:
$R = N \times T$
When the source base is a multiple of the target (e.g., Base 10 to Base 5, factor
-
Transformation Matrix (
$D$ ): A diagonal matrix of powers of the base ratio$F$ , used to rescale the digits. -
Operation:
$R = N \times D$
The matrix operations produce a result vector
- Phase 1: Fraction Sweep (Left-to-Right): Iterates through the vector to clear denominators by pushing fractional remainders to the right-hand neighboring digit.
-
Phase 2: Carry Propagation (Right-to-Left): Performs standard positional carry and borrow operations to ensure every digit is within the valid range
$[0, |\text{Base}| - 1]$ .
popup.html- The user interface.popup.js- The core logic (BigInt Math, Matrix generation, Normalization).style.css- Styling for the visualization cards.manifest.json- Chrome extension configuration.
This project is open-source. Algorithm concepts based on "Alternative Algorithms for Integer Base Conversion" (Steve Palmer, 2007).