calling functions in ts incurs pretty heavy penalty, so if you want to up performance dont subdivide functions.
Yeah stuff like .length() is making this slower
This is true. I didn't divide it up for the sake of not destroying the algorithm too much. Wanted to keep the similarities intact. However, now it is time to merge everything together to normalize the function into bigger solid ones.
also use only local or global vars for fastest performance
I thought this would make a great impact on the performance, but when I removed the use of object and went global all the way, it in fact went slower. Could be due to the concatenation of array strings.
Objects also store all variables inside them as strings (even if it's obviously an integer or a float), so avoid storing the actual number information in them and delegate it to global variables.
I didn't know this, but I know one thing from what I found out while developing this: I could use the numbers fine without any penalty on result or performance. It actually, as mentioned previously, went slower when I tried to optimized it through global variables. However, I did not try any numbers that reaches anything higher than 6 digits in size.
Once all those things are done, then you should have yourself a much much faster library (I can probably send some pull requests your way for this)
I would be happy if you could provide some pushes. As long as the general algorithm is like it is now, unless a better one is found, then this is the fastest library when it were written in JavaScript. Keep in mind that as this is TorqueScript, several more changes needs to be made in order to optimize this further. I am all ears for improvement suggestions, but please keep in mind that test results through the included test suit needs to be provided to make sure that the speed is indeed faster. I'll update it later on to make it easier to see changes from previous runs.
On an another note, I added a quick way for the functional version to determine the size of the number and do a calculation directly on it instead of converting it to an array. The speeds have been updated to mirror this change.