Java BigDecimal inverse(final BigDecimal amount)

Here you can find the source of inverse(final BigDecimal amount)

Description

inverse

License

Apache License

Declaration

public static BigDecimal inverse(final BigDecimal amount) 

Method Source Code


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

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static BigDecimal inverse(final BigDecimal amount) {
        return amount.equals(BigDecimal.ZERO) ? amount : BigDecimal.ONE.divide(amount, RoundingMode.HALF_EVEN);
    }//from  www  .  j av a 2s. c o  m

    public static BigDecimal divide(final BigDecimal amount, final BigDecimal divideBy, final int scale) {
        return amount.setScale(scale, RoundingMode.HALF_EVEN).divide(divideBy, RoundingMode.HALF_EVEN);
    }
}

Related

  1. htmlFooter(String providerNo, int count, BigDecimal total)
  2. humanReadableByteCount(BigDecimal bytes, Boolean si)
  3. incRatio(BigDecimal o1, BigDecimal o2)
  4. intToBigDecimal(int i)
  5. intValue(BigDecimal a)
  6. invert(BigDecimal d)
  7. joinBigDecimals(List list)
  8. jsonNumberToBigDecimal(final JsonNumber n, final int defaultValue)
  9. limitScale(BigDecimal value, int scale)