Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12432


Ignore:
Timestamp:
06/12/15 11:14:39 (9 years ago)
Author:
pfleck
Message:

#2395
Use simple round-trip format for doubles because G17 prints some strange numbers (20.22 to 20.219999999999999999).
Some accuracy can still be lost on 64bit machines, but should be very rare and minimal.
double.MaxValue can still be parsed correctly, solving the problem of invalid value for the GUI.

Location:
trunk/sources/HeuristicLab.Data/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs

    r12431 r12432  
    5656    }
    5757    protected virtual string GetValue(int index) {
    58       return this[index].ToString("G17");
     58      return this[index].ToString("r");
    5959    }
    6060    protected virtual bool SetValue(string value, int index) {
  • trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs

    r12431 r12432  
    6161    }
    6262    protected virtual string GetValue(int rowIndex, int columIndex) {
    63       return this[rowIndex, columIndex].ToString("G17");
     63      return this[rowIndex, columIndex].ToString("r");
    6464    }
    6565    protected virtual bool SetValue(string value, int rowIndex, int columnIndex) {
  • trunk/sources/HeuristicLab.Data/3.3/DoubleRange.cs

    r12431 r12432  
    5656
    5757    public override string ToString() {
    58       return string.Format("Start: {0:G17}, End: {1:G17}", Start, End);
     58      return string.Format("Start: {0:r}, End: {1:r}", Start, End);
    5959    }
    6060
  • trunk/sources/HeuristicLab.Data/3.3/DoubleValue.cs

    r12431 r12432  
    4848
    4949    public override string ToString() {
    50       return Value.ToString("G17");  // round-trip format
    51       // Note that the round-trip format "r" can still lead to different values when run on an 64-bit machine, therefore using G17 instead.
    52       // (https://msdn.microsoft.com/en-us/library/kfsatb94.aspx)
     50      return Value.ToString("r");  // round-trip format
    5351    }
    5452
Note: See TracChangeset for help on using the changeset viewer.