Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5705 for trunk


Ignore:
Timestamp:
03/16/11 12:13:16 (14 years ago)
Author:
mkommend
Message:

#1443: Corrected handling of infinity in extension method IsAlmost.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/DoubleExtensions.cs

    r5445 r5705  
    2424  public static class DoubleExtensions {
    2525    public static bool IsAlmost(this double x, double y) {
     26      if (double.IsPositiveInfinity(x)) return double.IsPositiveInfinity(y);
     27      if (double.IsNegativeInfinity(x)) return double.IsNegativeInfinity(y);
     28
    2629      return Math.Abs(x - y) < 1.0E-12;
    2730    }
Note: See TracChangeset for help on using the changeset viewer.