Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

public class Main {
    /**
     * Rounds a double down via passed in amount and places
     * @param value
     * @param places
     * @return
     */
    public static double roundDown(double value, int places) {
        if (places < 0)
            throw new IllegalArgumentException();

        BigDecimal bd = new BigDecimal(value);
        bd = bd.setScale(places, RoundingMode.FLOOR);
        return bd.doubleValue();
    }
}