1. ## calculator

how can I program a caltulator which does process between 2,3,4,5,6,7,8,9,10 based numbers.

for example asuume that these are two based numbers (111)+(101)=1000

2. first make a function that can convert a base 10 number to a base 2, 3, 4, 5 etc.

and vice versa

too late to remember the method ;0

so basically you do the math w/ base 10
so

111 (base2) + 101 (base2) is really
7 + 5
so a computer can understand that

do the math

convert back to base2

Making the function is the hard part. I forgot how to convert from anything other than base 2 and 8 =/

3. You are asking about the algorithm or about the coding, I mean do you know how to convert between bases or you not?
What exactly do you need to know.

4. both algoritihm and coding

5. ## here

ok i can give you algorithy for base 10 to base 2

take a base 10 number ie 15
module (% operator) by 2
that is your remainer, which is the least significant digit of the base 2 number
then divide by 2, which gives you 7 (least it should w/ int)
module again by 2
that remainer is your next least sig. digit
divide by 2
repeate till your division = 0

*edit*
click on the 'edit' button to visualize how things should line up properly
*edit*
*edit*
mebe this helps
*edit*
3 edits' later, i give up
*edit*

so for 15:
15%2 =_____1__| least sig. digit
15/2 = 7 _______|
7%2 = _____ 1__|
7/2 = 3 ________|
3%2 = _____1__|
3/2 = 1 ________|
1%2 = _____1__| most sig. digit
1/2 = 0 end_____V
=============
1111 = 15 (base 2)

btw, search this stuff on the web, i'm sure they're a zillion resources. Keyword = converting base or converting base 10, 2

6. If you don't know how to do it mathimaticaly, my advice to you is to learn that first then try to write the code.

the example of converting from base 10 to base 2, will work on all conversion operations from a base to a smaller base.

Try searching the web or writting the code for the base 10 to 2 converter and see what you will get.

7. Originally posted by ammar

the example of converting from base 10 to base 2, will work on all conversion operations from a base to a smaller base.

oh yeah haha, forgot

8. Here's a function that converts a number of any base (1-36) in string form to an integer.
Code:
```        //String to integer
int P__StrToNum(const char* str, int base)
{
unsigned int digit, number = 0;
while (*str) {
if (isdigit(*str)) digit = *str - '0';
else if (islower(*str)) digit = *str - 'a' + 10;
else digit = *str - 'A' + 10;
number = number * base + digit;
str++; }
return(number);
}```

9. This I found on this site a while ago............

Should help

10. Oh, and this.......

Not my work, but look and you will find..

11. thank you very much.

12. but my problem is a little more complicated look at this;
111+101=1000 in a 2 based additon process.
how can I make a calculator which does a process like this.
I want a calculator which makes 4 process between based numbers.

13. after the numbers (111, 102, etc..) are inputted and stored in an integer variable, just convert them to base 10 then do the calculation then convert then back to base 2 so its outputted the way you inputted them...

did you get all that?

14. Dont think it was understood .

But all the answers are in my two attachments. Use Baseconv.zip to change to base 10 (if you must), do the calculation, and change back- Then use the code in calc program.

Sorted