Why is a round-trip conversion via a string not safe for a double?
I found the bug. .NET does the following in clr\src\vm\comnumber.cpp: DoubleToNumber(value, DOUBLE_PRECISION, &number); if (number.scale == (int) SCALE_NAN) { gc.refRetVal = gc.numfmt->sNaN; goto lExit; } if (number.scale == SCALE_INF) { gc.refRetVal = (number.sign? gc.numfmt->sNegativeInfinity: gc.numfmt->sPositiveInfinity); goto lExit; } NumberToDouble(&number, &dTest); if (dTest == value) { gc.refRetVal = NumberToString(&number, ‘G’, DOUBLE_PRECISION, gc.numfmt); goto lExit; } DoubleToNumber(value, … Read more