Here you can find the source of roundDown(double a)
public static int roundDown(double a)
//package com.java2s; //License from project: GNU General Public License public class Main { /** Returns the closest int to the argument, with ties rounding down. */ public static int roundDown(double a) { double r = a % 1; if (r < 0) r += 1;//from ww w. jav a 2 s. c om return r == 0.5 ? (int) Math.round(a) - 1 : (int) Math.round(a); } /** Returns the closest int to the argument, with ties rounding down. */ public static int roundDown(float a) { float r = a % 1; if (r < 0) r += 1; return r == 0.5f ? Math.round(a) - 1 : Math.round(a); } }