Wed 15 Jan 2003 01:56:51 PM UTC, original submission:
Double.Parse does not properly parse numbers with unrelevant digits (trailing 0). Unfortunately, real numbers are now printed with a fixed size and, therefore, unrelevant digits.
Moreveover, Double.Parse (actually System.Private.NumberParser.ParseDouble(String, NumberStyles, NumberFormatInfo) in ./System/Private/NumberParser.cs:1143) requires the exponent symbol (e|E) to be followed by a sign, while + should be considered as default.
Here is the output I have of the following test program :
$ cscc DoubleParse.cs -o DoubleParse.exe ; ilrun DoubleParse.exe
Attempting to parse [0.0]...
Failure : Attempt to negate the largest negative integer.
at System.Math.Abs(Int32) in ./System/Math.cs:78
at System.Private.NumberFormat.ScientificFormatter.Format(Object, IFormatProvider) in ./System/Private/NumberFormat/ScientificFormatter.cs:93
at System.Private.NumberFormat.GeneralFormatter.Format(Object, IFormatProvider) in ./System/Private/NumberFormat/GeneralFormatter.cs:96
at System.Double.ToString(String, IFormatProvider) in ./System/Double.cs:109
at System.String.Format(IFormatProvider, String, Object[]) in ./System/String.cs:776
at System.String.Format(String, Object) in ./System/String.cs:585
at System.IO.TextWriter.WriteLine(String, Object) in ./System/IO/TextWriter.cs:199
at DoubleParse.Main()
Attempting to parse [0.5]...
Success ;-) : [0.500000000000000]
Attempting to parse [0.500000000000000]...
Success ;-) : [0.138223616000000]
Attempting to parse [1.13]...
Success ;-) : [1.130000000000000]
Attempting to parse [1.130000000000000]...
Success ;-) : [1.422485196800000]
Attempting to parse [1e+2]...
Success ;-) : [100.000000000000000]
Attempting to parse [1e-2]...
Success ;-) : [0.010000000000000]
Attempting to parse [1e2]...
Failure : Exponent notation must include a sign on the exponent
at System.Private.NumberParser.ParseDouble(String, NumberStyles, NumberFormatInfo) in ./System/Private/NumberParser.cs:1143
at System.Double.Parse(String, NumberStyles, IFormatProvider) in ./System/Double.cs:120
at System.Double.Parse(String) in ./System/Double.cs:142
at DoubleParse.Main()
Have fun !
|