Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/07/15 15:38:56 (10 years ago)
Author:
pfleck
Message:

#2301 Use decimal instead of double for the DefineArithmeticProgressionDialog and in the CreateExperimentDialog.
Note, when using decimal only during the generate process but not during some calculations (e.g. determining meaningful step sizes), numeric inaccuracies occur.
Therefore some calculations now uses decimal instead of double values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r12012 r12293  
    264264      var parameter = (IValueParameter)generateButton.Tag;
    265265      bool integerOnly = intParameters.ContainsKey(parameter);
    266       double min = 0, max = 1, step = 1;
     266      decimal min = 0, max = 1, step = 1;
    267267      #region Try to calculate some meaningful values
    268268      if (integerOnly) {
     
    276276        int len = doubleParameters[parameter].Length;
    277277        if (len > 0) {
    278           min = doubleParameters[parameter].Min();
    279           max = doubleParameters[parameter].Max();
    280           step = len >= 2 ? Math.Abs((doubleParameters[parameter][len - 1] - doubleParameters[parameter][len - 2])) : 1;
     278          min = (decimal)doubleParameters[parameter].Min();
     279          max = (decimal)doubleParameters[parameter].Max();
     280          step = len >= 2 ? Math.Abs(((decimal)doubleParameters[parameter][len - 1] - (decimal)doubleParameters[parameter][len - 2])) : 1m;
    281281        }
    282282      }
     
    292292          } else {
    293293            doubleParameters[parameter].Reset -= new EventHandler(ValuesArray_Reset);
    294             doubleParameters[parameter] = new DoubleArray(values.ToArray());
     294            doubleParameters[parameter] = new DoubleArray(values.Select(x => (double)x).ToArray());
    295295            doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
    296296            stringConvertibleArrayView.Content = doubleParameters[parameter];
Note: See TracChangeset for help on using the changeset viewer.