Here you can find the source of epsilonFloor(double d)
Parameter | Description |
---|---|
d | the double that we would like the floor value for |
public static double epsilonFloor(double d)
//package com.java2s; /*// w ww. j av a2s .c o m * Copyright 2002 (C) Bryan McRoberts <merton_monk@yahoo.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * */ public class Main { static final private double epsilon = 0.0001d; /** * protect the floor function from the vagaries of floating point precision. * @param d the double that we would like the floor value for * @return the floor after adding epsilon */ public static double epsilonFloor(double d) { return Math.floor(d + epsilon); } }