blink0k wrote: "That is very very nice! Thanks!
How would i say, calculate a percentage of the value or apply/use it in an equation?"
It depends. I haven't run/checked this code, so consider it pseudo code for now, but it should work something like the examples below. For equations, I'd just do what I recommended and keep them contained to the LowInt value where possible. So for an addition example:
LowInt = LowInt + 5843028
Then with the bounds check I posted earlier, if it passes the next billion tier, values are transferred and offset as needed automatically. If the value going in is over 1-billion, then you just need to add the number of billions to the HighInt value first, then add what remains to the LowInt value. I'll illustrate this in code below with a percentage increase example.
For percentages with something over a billion, you can transfer the billion state over to a float, so something like this to calcuate a 40% percentage for a starting value of 1,250,000,000:
FloatHighInt# = HighInt * 0.4 ` reduce to percentage factor
TempHighInt = FloatHighInt# * 1000000000 ` restore to billions value
This will equal 0.4 in the float value, so equivalent to 400,000,000 stored in the TempHighInt value. You can single line the calculation if you want to, but I've spread it out for clarity/simplicity. Then be sure to apply the same percentage reduction to your LowInt value (which is 250,000,000) also:
This will equal 100,000,000. So now all you need to do is add the two together with the TempHighInt value representing its (reduced) value in billions ratio plus the LowInt value at its 1:1 ratio. So:
LowInt=LowInt + TempHighInt ` add the values back together
HighInt = HighInt - 1 ` to take away the 1-billion level it was holding, this can be done a number of different ways as needed depending on the scope of the calc
And your target value is 500,000,000 for a direct 1,250,000,000 * 0.4 calculation, so it'll match. It works in the other direction also, you just need to account for the expanding billions value. So for 280% (we'll go over a billion added for this to show how it can work, calcs spread out to help illustrate steps):
FloatHighInt# = HighInt * 2.8 ` increase to percentage factor, this will equal 2.8 billion, so hold it for now in the float variable
HighInt = trunc(FloatHighInt) ` now step increase the HighInt Value by the additional billion needed, this will set it to '2' from the value above
FloatHighInt# = FloatHighInt# - HighInt ` this leaves us with 0.8 billion that will still need to be added to the total in the same way as the earlier example
LowInt = LowInt * 2.8 ` This increases the LowInt value also, if it passes a billion, you'll need to add it to the HighInt value, this doesn't though
LowInt = LowInt + (FloatHighInt# * 1000000000) ` this will equal 1.5 billion total, which will be auto-corrected by the bounds check
And if you are running the bounds check routine I posted earlier, this will automatically correct the additional billion that the HighInt value needs to increase by while keeping everything within the limits of the values you need to manage. So in this example, HighInt increases to '2' for the 2 billion, and LowInt increases to 700,000,000 initially, then another 800,000,000 after including the left over value from the HighInt increase. The bounds check will add another 1 to the HighInt for the 1.5-billion LowInt increases to, then LowInt will be cropped to 500-million. So the total result will be 3-billion (HighInt = 3) and 500-million (LowInt = 500000000). And that is the same result you'd get with a direct 1,250,000,000 * 2.8 calculation.