Calculators have always fascinated me. For that matter numbers. Even before I could bring Dad's calculator to school I was busily working on paper with digits 0-9. Fascinated, just ... fascinated by what they meant, what they implied, and what they COULD mean with new definitions.

When I finally understood computers, I was quite interested. No, that's not the right word. I was OBSESSED. Obsessed to the point of mania would it could mean. What I could do. And what I could do with tools that worked with these numbers. Tools within tools. Numbers within numbers ...

So perhaps this is a work of love, real love, for the majesty and magnificence of numbers.

With that out of the way, let me show you what I have done.

I suppose it's a bit of a calculator, but with a difference. You can have ANY number of digits. And I mean any. Right now I have it scaled for 64-digits. That includes positive and negative.

Most importantly, it does NOT do it a single number at a time as you can tell. No, it truly does add and subtract every digit intelligently. So if you have 16-digits set. Then it will take no more than 5-loops or 80 looped statements to get the right value.

- [1st loop] retrieve digits
- [2nd loop] find largest numbers
- [3rd loop] add digits (if adding)
- [4th loop] subtract digits (if subtracting)
- [5th loop] locate beginning of return value
- [6th loop] send return value to variable

NOT 1-million loops to get a value of 1-million.

So far it's just addition and subtraction, but maybe that's because I don't really know how to write simple code to multiply or divide without a calculator or computer.

Anyways, it does addition and subtraction quite well, and as mentioned, with any number of digits. I'm not kidding about that.

Try out the sample program included and you have a few controls available to you.

Press LEFT and RIGHT to increase and decrease randomly by several thousand.

Hold (O) and LEFT and RIGHT to do it 100 times over.

Tap (X) to double your value. This will rapidly increase the amount. Remember, I just have it keyed to work no more than 64-digits at the moment. You can always change that.

Tap UP to take out the last digit in your number. A good way to shrink the value.

Try this for a test.

Hold (O) and RIGHT to get it up to about 50-million.

Now hold (X) for a bit to see it dramatically increase by doubling the total each time. You can check my work with a calculator too if you want.

Seems to work well for positive numbers. Alright, either hold (O) and LEFT or UP to get the value back down. Test it for negative numbers now.

Here's where my hardest coding came in. To bounce back and forth between positive and negative WITHOUT getting the wrong value. Test it though, please. I want this to work right. I think it does. I hope it doesn't get any errors.

I feel a little like Willy Wonka developing a new candy. As he (Gene Wilder) said, "I don't think so. Few more tests."

Anyways, there you have it. A single function that you can use in your own code to count well past trillions. Definitely good for scoreboards or long-playing RPGs with huge experience point values.

Likely you can find other more interesting uses for it.

Thinking, @kitheif ... Oh, you want to know how I'm doing it solely with strings ?

Pretty much the same way you do it back in school. If you have a nine for instance and want to add one, you change that nine to a zero and increase by one the digit to the left.

The opposite is also true. If you are decreasing a number and want to subtract one and the digit is already zero then change it to 9 and decrease the digit to the left. If there are no more digits, then instead change it to negative one.

Instead of my code doing it one digit at a time though it does it 2-numbers at a time so you are adding and subtracting any number from 0 to 9 with 0 to 9 and changing the other digits accordingly.

That's about the size of it. Oh yes, and it does it VERY quickly, too which is why you can quickly double the total (X) key, it and add many varied digits as well. :D

Ooo thank you for answering my vague question

that's interesting

I remember being shown how the english number system uses a base 10 system - so it's nice to hear the function of what occurs when the base ten reaches it's limit.

Questions!

So is it the solving of two-numbers-at-a-time that makes your code fast?

What if you did three?

What part of my computer is responsible for number counting usually?.. The CPU? The GPU?..

And does is take advantage of what your doing here?

All computers can only do one task at a time (unless you are referring to multiprocessors and I'm not going there). :)

No, @kitheif. My program does one digit per position at a time but it does not do one number at a time. It does not increase and decrease only by one number.

It takes the two numbers, adds them and continues for the length of digits.

In this it's quite speedy.

To answer your other question,

https://www.omnisci.com/learn/resources/technical-glossary/CPU-to-GPU

[Please log in to post a comment]