Free cookie consent management tool by TermsFeed Policy Generator

Opened 9 years ago

Closed 9 years ago

#2395 closed defect (done)

double.MaxValue cannot be parsed from string

Reported by: pfleck Owned by: mkommend
Priority: medium Milestone: HeuristicLab 3.3.12
Component: Data Version: 3.3.11
Keywords: Cc:

Description

When using a DoubleArray, DoubleMatrix or DoubleRange and a value equals double.MaxValue the views cannot parse the string-representation back to double. This blocks the view because the invalid value have to be changed.

The problem occurs because the ToString of double rounds the double to a value which does not fit into double anymore. (see http://stackoverflow.com/questions/766918/convert-1-79769313486232e308-to-double-without-overflowexception)

To fix this, the ToString should be used with the format string "R" or "G17", like it is done in the DoubleValue. This guarantees that converting the double to string and parsing it back yields the same double value. (see https://msdn.microsoft.com/en-us/library/kfsatb94.aspx)

Change History (6)

comment:1 Changed 9 years ago by pfleck

  • Status changed from new to accepted

comment:2 Changed 9 years ago by pfleck

r12431 Fixed parsing issues by using the G17 format.

comment:3 Changed 9 years ago by pfleck

r12432 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.

comment:4 Changed 9 years ago by pfleck

  • Owner changed from pfleck to mkommend
  • Status changed from accepted to reviewing

comment:5 Changed 9 years ago by mkommend

  • Status changed from reviewing to readytorelease

r12433: Minor change in DoubleValue.GetValue.

comment:6 Changed 9 years ago by mkommend

  • Resolution set to done
  • Status changed from readytorelease to closed

r12705: Merged r12431, r12432, r12433 into stable.

Note: See TracTickets for help on using tickets.