Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.math.BigDecimal;

public class Main {
    public static Object round(Object value, int places) {
        // if (places < 0) throw new IllegalArgumentException();
        if (places < 0 || !(value instanceof Double)) {
            return value;
        }
        BigDecimal bd = new BigDecimal((Double) value);
        bd = bd.setScale(places, BigDecimal.ROUND_HALF_UP);
        return bd.doubleValue();
    }
}