Java BigDecimal getDigits(BigDecimal value)

Here you can find the source of getDigits(BigDecimal value)

Description

get Digits

License

Open Source License

Declaration

public static int getDigits(BigDecimal value) 

Method Source Code

//package com.java2s;
/***********************************************************************************
 * AlgoTrader Enterprise Trading Framework
 *
 * Copyright (C) 2015 AlgoTrader GmbH - All rights reserved
 *
 * All information contained herein is, and remains the property of AlgoTrader GmbH.
 * The intellectual and technical concepts contained herein are proprietary to
 * AlgoTrader GmbH. Modification, translation, reverse engineering, decompilation,
 * disassembly or reproduction of this material is strictly forbidden unless prior
 * written permission is obtained from AlgoTrader GmbH
 *
 * Fur detailed terms and conditions consult the file LICENSE.txt or contact
 *
 * AlgoTrader GmbH/*  ww  w  .  j  a  v a2s.  c  o m*/
 * Aeschstrasse 6
 * 8834 Schindellegi
 ***********************************************************************************/

import java.math.BigDecimal;

public class Main {
    public static int getDigits(BigDecimal value) {
        String string = value.stripTrailingZeros().toPlainString();
        int index = string.indexOf(".");
        int scale = index < 0 ? 0 : string.length() - index - 1;
        return scale;
    }
}

Related

  1. getBtcToBuy(BigDecimal ask, BigDecimal bid, BigDecimal fee, BigDecimal scalpAmount)
  2. getByteArrayFromBigDecimalArray(Object value)
  3. getConversionUsdBased(final String destinycode, final BigDecimal amount, final BigDecimal usdBasedBaseRate, BigDecimal usdBasedDestinyRate)
  4. getDateFromRank(BigDecimal rank)
  5. getDepositAmount(Boolean isReceipt, BigDecimal amount)
  6. getDistance(BigDecimal sourceLatitude, BigDecimal sourceLongitude, BigDecimal destLatitude, BigDecimal destLongitude)
  7. getDividedBigDecimal(final int nDividend, final int nDivisor)
  8. getDoubleBigDecimal(String amount, int afterDot)
  9. getEndTimeByManDay(Date serviceStartTime, BigDecimal manDay)