private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
Multiplication.multiplyByTenPow(subtrahend.getUnscaledValue(),diffScale)), this.scale); } else {// case s2 > s1 : [ u1 * 10 ^ (s2 - s1) - u2 , s2 ] diffScale = -diffScale; return valueOf(this.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale]-subtrahend.smallValue,subtrahend.scale); return new BigDecimal(Multiplication.multiplyByTenPow(this.getUnscaledValue(),diffScale) .subtract(subtrahend.getUnscaledValue()), subtrahend.scale);
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
return valueOf(this.smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)diffScale],newScale); return new BigDecimal(Multiplication.multiplyByTenPow(getUnscaledValue(),(int)diffScale), newScale);
scaledDivisor = Multiplication.multiplyByTenPow(scaledDivisor, (int)diffScale); } else if (diffScale < 0) { scaledDividend = Multiplication.multiplyByTenPow(scaledDividend, (int)-diffScale);
private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
private static BigDecimal addAndMult10(BigDecimal thisValue,BigDecimal augend, int diffScale) { if(diffScale < MathUtils.LONG_POWERS_OF_TEN.length && Math.max(thisValue.bitLength,augend.bitLength+LONG_POWERS_OF_TEN_BIT_LENGTH[diffScale])+1<64) { return valueOf(thisValue.smallValue+augend.smallValue*MathUtils.LONG_POWERS_OF_TEN[diffScale],thisValue.scale); } else { BigInt bi = Multiplication.multiplyByTenPow(augend.getUnscaledValue(),diffScale).getBigInt(); bi.add(thisValue.getUnscaledValue().getBigInt()); return new BigDecimal(new BigInteger(bi), thisValue.scale); } }
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
private BigDecimal movePoint(long newScale) { if (isZero()) { return zeroScaledBy(Math.max(newScale, 0)); } /* * When: 'n'== Integer.MIN_VALUE isn't possible to call to * movePointRight(-n) since -Integer.MIN_VALUE == Integer.MIN_VALUE */ if(newScale >= 0) { if(bitLength < 64) { return valueOf(smallValue, safeLongToInt(newScale)); } return new BigDecimal(getUnscaledValue(), safeLongToInt(newScale)); } if(-newScale < MathUtils.LONG_POWERS_OF_TEN.length && bitLength + LONG_POWERS_OF_TEN_BIT_LENGTH[(int)-newScale] < 64 ) { return valueOf(smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)-newScale],0); } return new BigDecimal(Multiplication.multiplyByTenPow( getUnscaledValue(), safeLongToInt(-newScale)), 0); }
return valueOf(this.smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)diffScale],newScale); return new BigDecimal(Multiplication.multiplyByTenPow(getUnscaledValue(),(int)diffScale), newScale);
return valueOf(this.smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)diffScale],newScale); return new BigDecimal(Multiplication.multiplyByTenPow(getUnscaledValue(),(int)diffScale), newScale);
return valueOf(this.smallValue*MathUtils.LONG_POWERS_OF_TEN[(int)diffScale],newScale); return new BigDecimal(Multiplication.multiplyByTenPow(getUnscaledValue(),(int)diffScale), newScale);