Blockland Forums > Modification Help
[Library] BigInteger - Too big numbers to handle yourself
<< < (2/2)
Kyuande:
Yeah stuff like .length() is making this slower
mctwist:

--- Quote from: Conan on January 19, 2018, 08:21:35 PM ---calling functions in ts incurs pretty heavy penalty, so if you want to up performance dont subdivide functions.

--- End quote ---

--- Quote from: Kyuande on January 20, 2018, 10:10:06 AM ---Yeah stuff like .length() is making this slower

--- End quote ---

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.


--- Quote from: Conan on January 19, 2018, 08:21:35 PM ---also use only local or global vars for fastest performance

--- End quote ---

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.


--- Quote from: Ipquarx on January 19, 2018, 09:15:27 PM ---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.

--- End quote ---

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.


--- Quote from: Ipquarx on January 19, 2018, 09:15:27 PM ---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)

--- End quote ---

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.
Potatoh:
can it calculate pi
Ipquarx:

--- Quote from: Potatoh on January 25, 2018, 05:48:17 PM ---can it calculate pi

--- End quote ---
i mean theoretically yes but it would be much slower than using a TCPobject to grab digits of pi off an external website
mctwist:

--- Quote from: Potatoh on January 25, 2018, 05:48:17 PM ---can it calculate pi

--- End quote ---

Like Ipquarx said, but you need to handle it yourself. This library does not support floats, so you need to simulate floats through an integer.
Navigation
Message Index
Previous page

Go to full version