mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8183912: java.math.BigDecimal.movePointLeft() should return this if called with zero argument
Reviewed-by: rriggs
This commit is contained in:
parent
f398c3dcd2
commit
135d5dc279
1 changed files with 4 additions and 0 deletions
|
@ -2871,6 +2871,8 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
|||
* @throws ArithmeticException if scale overflows.
|
||||
*/
|
||||
public BigDecimal movePointLeft(int n) {
|
||||
if (n == 0) return this;
|
||||
|
||||
// Cannot use movePointRight(-n) in case of n==Integer.MIN_VALUE
|
||||
int newScale = checkScale((long)scale + n);
|
||||
BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0);
|
||||
|
@ -2893,6 +2895,8 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
|||
* @throws ArithmeticException if scale overflows.
|
||||
*/
|
||||
public BigDecimal movePointRight(int n) {
|
||||
if (n == 0) return this;
|
||||
|
||||
// Cannot use movePointLeft(-n) in case of n==Integer.MIN_VALUE
|
||||
int newScale = checkScale((long)scale - n);
|
||||
BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue