public static function almostEqual($a, $b, $epsilon = 0.0000000001)
    {
        $diff = abs($a - $b);

        if ($a === $b) {
            // just compare values, handles e.g. INF
            return true;
        } elseif ($a === 0.0 || $b === 0.0 || $diff < self::FLOAT_MIN) {
            // a or b is zero or both are extremely close to it
            // relative error is less meaningful here
            return $diff < ($epsilon * self::FLOAT_MIN);
        } else {
            // use relative error
            $abs_a = abs($a);
            $abs_b = abs($b);
            return $diff / ($abs_a + $abs_b) < $epsilon;
        }
    }