Does the following statement holds for any double (Java primitive double precision IEEE-754) except NaN:
Double.parseDouble(String.valueOf(d)) == d
Said otherwise, does parsing a serialized (using String.valueOf()) double value always yields the exact original double?
With the exception of NaN as you’ve said, yes, that invariant should hold. If not, that’s a JDK bug right there.
Double.toStringsays this in its Javadoc:To summarize, it returns enough digits to identify this double uniquely, so
Double.parseDoubleshould return the exact same double that was converted to a string.