Here you can find the source of round(BigDecimal decimal)
Parameter | Description |
---|---|
decimal | the value to round |
static long round(BigDecimal decimal)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { private static final RoundingMode ROUNDING_MODE = RoundingMode.HALF_UP; /**//from w w w . j a v a 2s . c om * Rounds the value to a long using {@link java.math.RoundingMode#HALF_UP} * * @param decimal the value to round * @return rounded value */ static long round(BigDecimal decimal) { return decimal.setScale(0, ROUNDING_MODE).longValue(); } static long round(Double decimal) { return round(BigDecimal.valueOf(decimal)); } }