java.lang.Object
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.DoubleCompare

public final class DoubleCompare extends Object
DoubleCompare class. Compares two doubles except for the last two bits of the mantissa.

Copyright (c) 2009-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Author:
Mamadou Seck
  • Method Details

    • compare

      public static int compare(double d1, double d2)
      Fuzzy compare of two double variables. When they differ less than 4 ulps, that they are equal.
      Parameters:
      d1 - double; the first double to compare
      d2 - double; the second double to compare
      Returns:
      0 if (almost) equal, -1 of d1 < d2, and 1 if d1 > d2.
    • main

      public static void main(String[] args)
      Test.
      Parameters:
      args - String[]; empty