Package java.math

Examples of java.math.BigDecimal.scale()


    else {
      bigNum = new BigDecimal( num.toString() ).stripTrailingZeros();
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }

  private void validateParameters() {
View Full Code Here


    BigDecimal bigNum = getBigDecimalValue( str );
    if ( bigNum == null ) {
      return false;
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }
View Full Code Here

    if ( bigNum == null ) {
      return false;
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }

  private BigDecimal getBigDecimalValue(String str) {
View Full Code Here

    if ( bigNum == null ) {
      return false;
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }

  private BigDecimal getBigDecimalValue(String str) {
View Full Code Here

      // the standard rules below.
      isNegative = false; // except that the sign bit is ignored
    }
    bd = convertToBigDecimal(exponent, fracBits);
   
    return formatBigInteger(isNegative, bd.unscaledValue(), bd.scale());
  }

  private static BigDecimal convertToBigDecimal(int exponent, long fracBits) {
    byte[] joob = {
        (byte) (fracBits >> 48),  
View Full Code Here

                         throws BAD_OPERATION
  {
    BigDecimal expectedReturn = new BigDecimal("123.456");
    any.insert_fixed(expectedReturn,
                     orb.create_fixed_tc((short) 6,
                                         (short) expectedReturn.scale()
                                        )
                    );

    BigDecimal actualReturn = any.extract_fixed();
    assertEquals("fixed", expectedReturn, actualReturn);
View Full Code Here

        case 2:
            return new BigRational((BigInteger)n,BigInteger.ONE);
        case 3: {
                BigDecimal decimal=(BigDecimal)n;
                // This method assumes that all BigDecimals actually have some decimal digits.
                assert decimal.scale()>0;
                return new BigRational(decimal.unscaledValue(),BigInteger.TEN.pow(decimal.scale()));
            }
        default:
            throw new IllegalArgumentException();
        }
View Full Code Here

            return new BigRational((BigInteger)n,BigInteger.ONE);
        case 3: {
                BigDecimal decimal=(BigDecimal)n;
                // This method assumes that all BigDecimals actually have some decimal digits.
                assert decimal.scale()>0;
                return new BigRational(decimal.unscaledValue(),BigInteger.TEN.pow(decimal.scale()));
            }
        default:
            throw new IllegalArgumentException();
        }
    }
View Full Code Here

            else
                return ((BigInteger)bound).subtract(BigInteger.ONE);
        case 3: {
                // This method assumes that all BigDecimals actually have some decimal digits.
                BigDecimal bd=(BigDecimal)bound;
                assert bd.scale()>0;
                BigInteger bi=bd.toBigInteger();
                if (BoundaryDirection.LOWER.equals(boundaryDirection)) {
                    if (bd.compareTo(BigDecimal.ZERO)>0)
                        bi=bi.add(BigInteger.ONE);
                }
View Full Code Here

            case Types.SQL_NUMERIC :
            case Types.SQL_DECIMAL : {
                BigDecimal dec = (BigDecimal) a;

                if (scale != dec.scale()) {
                    dec = dec.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
                }

                int p = JavaSystem.precision(dec);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.