You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "westonpace (via GitHub)" <gi...@apache.org> on 2023/08/03 20:33:32 UTC
[GitHub] [arrow-rs] westonpace commented on pull request #4640: Increase output scale for decimal division
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org