Method and source check
Last checked:
Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.
Method
Validate every digit against the selected base, parse the signed integer with BigInt, then format it in bases 2, 8, 10, and 16.
value = Σ digit × base^place
Variables and units
- base
- 2, 8, 10, or 16
- value
- whole integer represented by all input digits
Worked example
1011 in base 2 equals 11 in base 10 and B in base 16.
Limitations
No rounding; validated integer strings are converted with BigInt and formatted exactly in bases 2, 8, 10, and 16, subject to available runtime memory.
- Whole numbers only; input digits must match the selected base. Very long accepted inputs may consume time or memory.
- 1011₂ → 11₁₀
- 102₂ and oops₁₀ rejected
- 9007199254740993₁₀ round trips unchanged