Java examples for java.lang:double
Checks if a given double is close to being zero.
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { double d = 2.45678; System.out.println(almostZero(d)); }//from w ww.j a va 2s . c o m public static final double ALMOST_ZERO = 0.00001; /** * Checks if a given double is close to being zero. * @param d * @return */ public static final boolean almostZero(double d) { return Math.abs(d) <= ALMOST_ZERO; } }