Hi there
I’m trying to work out a function which will enable me to add together many very large numbers.
As a quick explanation of its use – I currently work on several mod projects for different games, and i’ve scripted a crafting system that works by adding together substrings found on particular items in order to generate the resulting item.
Anyway, i’m looking to do my first public release but I thought in order to speed up people’s own creations using the system I could provide with it a webpage that could create the rather long and complex strings for them.
As javascript only allows numbers up to 17 digits (and I believe the biggest numbers in the system are 50+ digits long) I was looking for a way to add the strings together.
Here is an example of what I mean –
The items required for the system are listed with checkboxes next to them. Each carries its own unique value.
item 1 = 1;
item 2 = 10;
item 3 = 100;
item 4 = 1000;
item 5 = 10000;
etc.etc.
I’m trying to come up with a way to add these values together as strings. In essence, instead of using addition I was hoping to find some way of using the strings length then simply replace() the appropriate character with a “1”.
The problems I could think of though, and that have prevented me from coding this myself (my javascript knowledge is pretty limited) –
1.
The resulting string must not be appended by zeros. However, obviously if a larger string is added to an existing string, then all the characters in the existing string must be pushed along. This was something I was unsure about – i.e testing between different lengths and acting accordingly.
Storing the values of the checked items. In the game’s system, you can only have a maximum of 8 items to create the resulting item (this is to stop the obvious flaw with this system). I’m unsure just how to store the values either in seperate vars or in an array, so that they can be removed and replaced easily should a checkbox be unchecked.
I hope that gives you a good idea of what i’m trying to do. Any info at all, even a nudge in the right direction, would be most appreciated. ?