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.
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.
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.