Java examples for java.lang:double
Determines if two double values are equivalents according to the precision.
//package com.java2s; public class Main { /**/*from ww w.j a v a 2 s . co m*/ * Precision for considering two double values equivalents */ public static final double PRECISION = 1e-10; /** * Determines if two double values are equivalents according to the precision. Two values are equivalent if * abs(x-y) <= precision * @param x First double value to be compared * @param y Second double value to be compared * @return <i>true</i> if <i>abs(x-y) <= precision</i>, <i>false</i> otherwise */ public static boolean equal(double x, double y) { return (Math.abs(x - y) <= PRECISION); } }