Decimal to Base B

We're glad you came by, but you might find what you're looking for elsewhere.

TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it.

Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope.

Routine Summary

Converts a decimal (base 10) number to a number in any other integer base B.

Inputs

A - The decimal number that you want to convert.
B/ - The base you want to convert A into.

Outputs

Ans - The base B representation of the decimal number, in list form.

Variables Used

{$variable}

Calculator Compatibility

TI-83/84/+/SE

Author

imcoraline

Download

[{$download}]

:iPart(ln(A)/ln(B
:BfPart(int(AB^(cumSum(binomcdf(Ans,0))-Ans-1))/B

This routine takes a positive whole decimal number (base 10), stored in A, and converts it to the equivalent representation in base B. The representation will be in list form. For example, the decimal number 32 is the base 2 number 100000, meaning the routine would result in the list {1,0,0,0,0,0}.

Note: This routine will not work for A<B.

It also may be important to note that adding 0’s to the front of a number will not change the decimal equivalent. For example, both 01101012 and 1101012 are equivalent to 5310.

Error Conditions

  • ERR:DATATYPE is thrown if A is complex or negative.
  • ERR:DOMAIN is thrown if A is 0 or less than B.
  • An error will not be thrown is A isn’t an integer. Nonetheless, the conversion will not work correctly.

Related Routines

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.