The BIGINT limitation is the reason I switched to decimal. It fixed many issues but broke a few things.TheMightyDude wrote:While that might work in most cases, using a clamp would give you more control over the actual value range, using ABS(...) would only make all values positive, this might work ok for now, but might cause issues later on, which might be why we never used it.JokerAce wrote: Would it be easier to correct the negative using abs()
...
No negative numbers result and it wouldn't limit the math output artificially.
Would this be a viable way to simplify the correction?
I haven't looked at the code yet but I'm guessing it would mean only minor changes would be needed versus clamping.
You'll know better than I but that's where my thinking and researching took me.
Like suppose the value got that high say 1 value more than the BIGINT (-9,223,372,036,854,775,807 to 9,223,372,036,854,775,807)
Soooo using the max value (i.e. 9,223,372,036,854,775,807 + 1) that will not equal 9,223,372,036,854,775,808, in fact it would equal 9.2233720368548E+18 which is 9,223,372,036,854,800,000.
So if you have the max value 9,223,372,036,854,775,807 you could add 1 or 10 or even 1000 it would still equal 9.2233720368548E+18 which is 9,223,372,036,854,800,000.
Using a calculator on my PC 9,223,372,036,854,775,807 + 1 equals -9,223,372,036,854,775,808, sadly on PHP it doesn't it equals 9.2233720368548E+18 which is where the issue lies.
This was some of the issues we have had with large numbers.
Also using either the Clamp or ABS versions, you are not resolving the issue, you are just sweeping it under the rug.
You really need to find out what's causing the actual issue and fix that.
What needs to really be done is lower everything and stop it getting that high in the first place and also putting in an absolute max value and when it hits that value it goes no higher.
Hence, the need for a clamp or abs.
Your last point is golden though and I have been thinking about how to do that since my game really got going and the numbers went astronomical super fast.
One potential way to fix that is to simply change the parameters of the economy.
Ships hold less, things cost less, 1 credit = 10,000 of the current credits basically. Also, the autotrade routes would have to have more limitations so people couldn't count on that to get rich as hell fast as hell.
Selling ships AND upgrades would gobble up some credits to prevent out of control economic scale.
Maybe using actual decimals to reduce the delta on trades.
Ore @
$1.67 selling - $1.98 buying
for example.
That would keep the totals down and keep more numbers on the right side of the decimal point which then gives you more room on the left side too.
Thoughts?