Uhhhh I’ve made a mistake.
Each integer in the 4-integer series represents a digit in base-10,000.
Why 10,000?
Because I’m a moron, apparently.
I had asked the question of “what’s the most-distant orbital distance (in meters) that I would need to keep track of?” and came up with a really big number, so I ignorantly just counted the base-10 digits of the result, and split them into equal groups of 4, rounding up, which means each group is 4 digits long, allowing it to store anything from 0 to 9,999. Hence: base-10,000.
So, uh… I sorta did this because it was natural and intuitive for me, and helped me figure out how the algorithms worked, but I failed to remember that I’m trying to make a version of BigNumber
that’s easier on the interpreter.
It has now occurred to me, just now, that my chosen base forces me to use an integer division operation, every time I want to iterate through digits. I just learned a few days ago that division was really slow, and I’ve now connected the dots as to why most multi-word integers are implemented with bases built around powers of 2, because it would let me replace all division with bit-shifting, which is so much faster.
My code for the MegaRegister
is really…uh…awkward, because it’s based entirely on constants and macros, to create a tightly-defined execution environment, both for speed and memory recycling. I didn’t want the CPU or interpreter to worry about execution stacks, or allocating memory for temporary variables. Of course, this isn’t the best corporate code, but corporate code probably won’t solve the BigNumber
problem.
I am now beholding all this code, and realizing I gotta rewrite a lot of macros and general code to accommodate a new base value, which would allow me to ditch division, in favor of bit-shifting.
Ugh.
Like, I was literally reading what @ramstrong had explained, and was like “Oh that’s interesting, he’s using bit-shifting instead of division. In a thread where I’m lamenting about how slow division is. I wonder why that is.”
MAYBE IT’S BECAUSE HE KNOWS WHAT HE’S DOING, AND MY IMPLEMENTATION COULD BE AS FAST AND EFFICIENT AS WHAT HE OUTLINES, IF I COULD REALIZE THAT DIVISION IS SLOW, AT EVERY LEVEL OF EXECUTION.
So, uh…I got a lot more spoons to gather, and a lot of rewriting to do…
I have this weird habit of constantly chasing the hard problems.
The really big shambling mess in the room, though, is that I’m doing a lot of coding and implementation, but I need to figure out a way to do timed tests, and compare what I got so far with BigNumber
. There’s a lot of work to reach a testing state, though, and there is still a possibility that this will be slower than BigNumber
.