Java Double Number Equal doubleEquals(Double d1, Double d2)

Here you can find the source of doubleEquals(Double d1, Double d2)

Description

Check if the two Double values are equal by checking that the absolute value between them is less than 0.01

License

Open Source License

Parameter

Parameter Description
d1 first double
d2 second double

Return

boolean, if true, the doubles are equal

Declaration

public static boolean doubleEquals(Double d1, Double d2) 

Method Source Code

//package com.java2s;
/*/*from   ww  w .  ja  va 2 s.c  o m*/
 * Copyright (c) Interactive Information R & D (I2RD) LLC.
 * All Rights Reserved.
 *
 * This software is confidential and proprietary information of
 * I2RD LLC ("Confidential Information"). You shall not disclose
 * such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered
 * into with I2RD.
 */

public class Main {
    /**
     * Check if the two Double values are equal by checking that the absolute value between them is less than 0.01
     *
     * @param d1 first double
     * @param d2 second double
     *
     * @return boolean, if true, the doubles are equal
     */
    public static boolean doubleEquals(Double d1, Double d2) {
        return Math.abs(d1 - d2) <= 0.01;
    }
}

Related

  1. doubleEqual(double v1, double v2)
  2. doubleEquality(double v1, double v2, double epsilon)
  3. doubleEquals(double a, double b)
  4. doubleEquals(double a, double b)
  5. doubleEquals(double a, double b)
  6. doubleEquals(double d1, double d2)
  7. doubleEquals(double d1, double d2, double epsilon)
  8. doubleEqualsWithTolerance(double a, double b, long maxFloatsBetween)