Java BigDecimal getLength(BigDecimal v)

Here you can find the source of getLength(BigDecimal v)

Description

get Length

License

Apache License

Declaration

private static int getLength(BigDecimal v) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    private static int getLength(BigDecimal v) {
        int signum = v.signum();
        if (signum == 0) { // Special case for zero
            return 1;
        }/*  ww  w. j av a  2 s  .  com*/
        return (signum < 0 ? 2 : 1) + (v.precision() + 1 + (v.scale() % 2 == 0 ? 0 : 1)) / 2;
    }
}

Related

  1. getFraction(BigDecimal b)
  2. getFractionalPart(BigDecimal value)
  3. getId(BigDecimal total, BigDecimal step)
  4. getIntLength(BigDecimal val)
  5. getIntValue(BigDecimal b)
  6. getLet(BigDecimal nl, BigDecimal el)
  7. getLetJp(BigDecimal nl)
  8. getLocalHourMinute(BigDecimal gmtHour)
  9. getMaxBigDecimal(@Nonnull final BigDecimal aValue, @Nonnull final BigDecimal... aValues)