Associated Topics || Dr. Math Home || Search Dr. Math

### TI-86 Base Conversion Program

```
Date: 03/19/2002 at 20:26:04
From: Amber
Subject: Base conversion

I need help writing a computer program for my TI-86 graphing
calculator. I have finished writing a program that can convert any
number in any base (one-ten) to base ten. Now I am writing a program
to convert any number in base ten to a given base. Here is an example
of what I am trying to do.

Convert this number 131255 (base ten) =  _________ (base 2)

That is one example that this program might solve.

I have tried to go about this a number of ways, and but I think that
what is holding me back is that I don't know how to convert this
problem by hand. Do you think you could lead me in the right
direction?

Thanks so much,
Amber
```

```
Date: 03/19/2002 at 20:46:52
From: Doctor Paul
Subject: Re: Base conversion

Find the largest power of 2 less than 131255:

2^17 = 131072

2^18 = 262144

Thus 131255 = 2^17 + ???

In fact, 131255 = 2^17 + 183

Now find the largest power of two less than 183

2^7 = 128
2^8 = 256

so 183 = 2^7 + ???

In fact, 183 = 2^7 + 55

Thus 131255 = 2^17 + 2^7 + 55

Now find the largest power of two less than 55...

repeat until you obtain:

131255 = 2^17 + 2^7 + 2^5 + 2^4 + 2^2 + 2^1 + 2^0

Thus 131255 in base 2 is:

100000000010110111

To convert the base 10 number n to base p, find the highest power of p
less than n and proceed as above. Be warned that you have to find
multiples as well, as demonstrated below:

convert 131255 to base 5:

5^7 = 78125

5^8 = 390625

How many times does 5^7 go into 131255? Just once (i.e., 2*5^7 >
131255).

So we write:  131255 = 1*5^7 + 53130

5^6 = 15625
5^7 = 78125

but 5^6 goes into 53130 more than once. In fact it goes three times.
Thus we write:

131255 = 1*5^7 + 3*5^6 + 6255

5^5 = 3125
5^6 = 15625

5^5 goes into 6255 twice

so 131255 = 1*5^7 + 3*5^6 + 2*5^5 + 5

and we're done.

So in base 5,

131255 = 13200010

The key to understanding this kind of conversion is to first
understand what is meant by the base ten representation of a number
such as 131255. It means:

1*10^5 + 3*10^4 + 1*10^3 + 2*10^2 + 5*10^1 + 5*10^0

The coefficients in front of the powers of 10 can be anything from 1
up to 9.

In base p, you want to write the number as a sum of multiples of
powers of p where the multiples can be anything from 1 up to p-1.

Does this help?  There's more in our archives about converting from
base 10 to other bases. Take a look there if you're still confused.

- Doctor Paul, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
High School Calculators, Computers
High School Number Theory

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search