Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13807


Ignore:
Timestamp:
04/27/16 22:03:01 (8 years ago)
Author:
bburlacu
Message:

#2594: Fix bug in Decimals method causing an infinite loop when the value is zero.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ChartUtil.cs

    r13764 r13807  
    4444
    4545    private static int Decimals(this double x) {
    46       if (double.IsInfinity(x) || double.IsNaN(x))
     46      if (x.IsAlmost(0) || double.IsInfinity(x) || double.IsNaN(x))
    4747        return 0;
    4848
     
    7171      return Math.Round(Math.Round(value * n) / n, precision);
    7272    }
     73
     74    private static bool IsAlmost(this double value, double other, double eps = 1e-12) {
     75      return Math.Abs(value - other) < eps;
     76    }
    7377  }
    7478}
Note: See TracChangeset for help on using the changeset viewer.