-
Couldn't load subscription status.
- Fork 7
Description
DecimalConstructor.cs is calling
Convert.ToDecimal(stringArg, CultureInfo.InvariantCulture)
So something like
System.Convert.ToDecimal("5E-1",CultureInfo.InvariantCulture)
Will throw a System.FormatException: Input string was not in a correct format. exception
This has bit us when using Microsoft.Spark (which takes this library as a dependency). We build C# UDFs that run in Spark which requires data to be serialized back and forth between the JVM and the CLR. In sparkland we have some decimal values that Spark decides to represent in scientific notation and when this gets pickled into the CLR we hit the above issue.
I did a bit of research and using something like
Decimal.Parse("5E-1, NumberStyles.AllowAny)
would work but is maybe too permissive. I think at a minimum we would need
Decimal.Parse("5E-1, NumberStyles.AllowLeadingSign | NumberStyles.DecimalPoint | NumberStyles.Exponent)
but there might be others.