NightOwl888 commented on issue #629: URL: https://github.com/apache/lucenenet/issues/629#issuecomment-1081963262
> @NightOwl888 > > > Do note that some cultures use alternate characters for the negative sign. So, for int.Parse() and long.Parse(), passing CultureInfo.InvariantCulture may be required if the input may contain negative numbers that don't match the culture of the current thread. > > Wouldn't you have to pass the `CultureInfo` for that culture in order for the `Parse()` method to correctly know how the negative number is represented? Seems like `CultureInfo.InvariantCulture` wouldn't contain that info? It depends on the source of the string you are parsing. If passed in from the UI, most likely the culture of the current thread is the right choice. However, data is frequently normalized to invariant culture when put into a file or database. Of course `float.Parse()` and `double.Parse()` are more obviously culture-sensitive (since many European nations reverse the usage of the comma and decimal point), but it is easy to overlook the negative sign on integral types because relatively few cultures replace the negative sign (although it is customizable by editing the properties of [NumberFormatInfo](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.numberformatinfo?view=net-6.0), which is returned from the [CultureInfo.NumberFormat](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.numberformat?view=net-6.0) property and the [CultureInfo.GetFormat()](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.getformat?view=net-6.0) method). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org