d60e7988736ed4358595e9c781b110a5bbb5f812 | Author: Liudmila Kornilova <kornilova203@gmail.com>
| 2019-08-08 17:36:19+08:00
Avoid result truncate in decimal operations
add (+), subtract (-) and multiply (*) operations:
* before:
* precision of result used to be always 34 (see MathContext.DECIMAL128)
* after:
* precision (number of significant digits) of result is at most 10000.
If result exceeds given precision it will be rounded using HALF_UP mode
division (/) operation:
* before:
* precision used to be always 34 (see MathContext.DECIMAL128)
* after:
* expected scale is set to minimum precision (32) minus estimated position of first digit in quotient
* scale should be at least as big as maximum scale of operands
* scale should not be less than 32
* scale should not be bigger than 1000
* if actual quotient scale is bigger than calculated scale then result is rounded using HALF_UP mode
* trailing zeros are stripped
modulo (%) operation:
* before:
* ArithmeticException used to occur when implicit division produces number with precision bigger
than 34 (see MathContext.DECIMAL128)
* after:
* No exception
patch by Liudmila Kornilova; reviewed by Benedict Elliott Smith for CASSANDRA-15232