Here you can find the source of stripTrailingZeros(final BigDecimal decimal)
Parameter | Description |
---|---|
decimal | the big decimal to strip, not null |
public static BigDecimal stripTrailingZeros(final BigDecimal decimal)
//package com.java2s; /**/*from www . j a va2s .c o m*/ * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ import java.math.BigDecimal; public class Main { /** Singleton zero. */ private static final BigDecimal ZERO = BigDecimal.valueOf(0, 0); /** * Strips trailing zeros from a BigDecimal. * <p> * The JDK does not strip zeros from zero. * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6480539">Bug 6480539</a>. * * @param decimal the big decimal to strip, not null * @return the stripped decimal, not null */ public static BigDecimal stripTrailingZeros(final BigDecimal decimal) { if (decimal.compareTo(ZERO) == 0) { return ZERO; } else { return decimal.stripTrailingZeros(); } } }