469,926 Members | 2,248 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Bug in Decimal.Parse()

GP
Decimal.Parse("100,5") returns 1005 when it should throw an
InvalidFormatException. The locale is US therefore the "," is a thousand
separator. Even if the parser confused it for the decimal separator it
should return 100.5. Maybe this bug is already logged but I couldn't find it
on MSDN.

--
Best regards,
Gianluca Pivato
--
Ice Tea Group, LLC
www.iceteagroup.com

Nov 16 '05 #1
3 3813
I would assume that it is simply ignoring the , characters in the string
.....

are you passing a NumberFormatInfo object or just calling
Double.Parse(string) ?

Indicates that the numeric string can have group separators; for example,
separating the hundreds from the thousands. Valid group separator characters
are determined by the NumberGroupSeparator and CurrencyGroupSeparator
properties of NumberFormatInfo and the number of digits in each group is
determined by the NumberGroupSizes and CurrencyGroupSizes properties of
NumberFormatInfo.
"GP" <no****@nospam.com> wrote in message
news:33****************@nwrddc02.gnilink.net...
Decimal.Parse("100,5") returns 1005 when it should throw an
InvalidFormatException. The locale is US therefore the "," is a thousand
separator. Even if the parser confused it for the decimal separator it
should return 100.5. Maybe this bug is already logged but I couldn't find it on MSDN.

--
Best regards,
Gianluca Pivato
--
Ice Tea Group, LLC
www.iceteagroup.com

Nov 16 '05 #2
To submit, the rotor code demonstrates the character is simply
skipped. It's relative location or it's scale is not checked to make
sure it is on a valid boundary. So Greg's notes are correct.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Greg Young" <gr********@planetbeach.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I would assume that it is simply ignoring the , characters in the string
....

are you passing a NumberFormatInfo object or just calling
Double.Parse(string) ?

Indicates that the numeric string can have group separators; for example,
separating the hundreds from the thousands. Valid group separator characters
are determined by the NumberGroupSeparator and CurrencyGroupSeparator
properties of NumberFormatInfo and the number of digits in each group is
determined by the NumberGroupSizes and CurrencyGroupSizes properties of
NumberFormatInfo.
"GP" <no****@nospam.com> wrote in message
news:33****************@nwrddc02.gnilink.net...
Decimal.Parse("100,5") returns 1005 when it should throw an
InvalidFormatException. The locale is US therefore the "," is a thousand
separator. Even if the parser confused it for the decimal separator it
should return 100.5. Maybe this bug is already logged but I couldn't find

it
on MSDN.

--
Best regards,
Gianluca Pivato
--
Ice Tea Group, LLC
www.iceteagroup.com


Nov 16 '05 #3
GP
A bug indeed: Decimal.Parse("1,1,1,1,1,1") returns 111111.
How to submit this bug to Microsoft? I also have spotted a logical mistake
in the C# specs (sec. 7.11.2) which result in wrong expression evaluation
but I don't know where to send this stuff.

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
To submit, the rotor code demonstrates the character is simply
skipped. It's relative location or it's scale is not checked to make
sure it is on a valid boundary. So Greg's notes are correct.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Greg Young" <gr********@planetbeach.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I would assume that it is simply ignoring the , characters in the string
....

are you passing a NumberFormatInfo object or just calling
Double.Parse(string) ?

Indicates that the numeric string can have group separators; for example, separating the hundreds from the thousands. Valid group separator characters are determined by the NumberGroupSeparator and CurrencyGroupSeparator
properties of NumberFormatInfo and the number of digits in each group is
determined by the NumberGroupSizes and CurrencyGroupSizes properties of
NumberFormatInfo.
"GP" <no****@nospam.com> wrote in message
news:33****************@nwrddc02.gnilink.net...
Decimal.Parse("100,5") returns 1005 when it should throw an
InvalidFormatException. The locale is US therefore the "," is a thousand separator. Even if the parser confused it for the decimal separator it
should return 100.5. Maybe this bug is already logged but I couldn't
find it
on MSDN.

--
Best regards,
Gianluca Pivato
--
Ice Tea Group, LLC
www.iceteagroup.com



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mark | last post: by
2 posts views Thread by probashi | last post: by
3 posts views Thread by Brenny | last post: by
3 posts views Thread by JenHu | last post: by
3 posts views Thread by Andrew Wrigley | last post: by
4 posts views Thread by =?Utf-8?B?cGF0cmlja2RyZA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.