westonpace commented on PR #4640:
URL: https://github.com/apache/arrow-rs/pull/4640#issuecomment-1664611342
This covers the first part of the rules but will quickly reach overflow if
you combine operations without using the second rules to reduce scale:
```
private static Decimal adjustScaleIfNeeded(int precision, int scale) {
if (precision > MAX_PRECISION) {
int minScale = Math.min(scale, MIN_ADJUSTED_SCALE);
int delta = precision - MAX_PRECISION;
precision = MAX_PRECISION;
scale = Math.max(scale - delta, minScale);
}
return new Decimal(precision, scale, 128);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]