You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convert.ChangeType calls float.Parse and double.Parse. They only match PositiveInfinitySymbol and NegativeInfinitySymbol of current culture, which differ from OS and versions. You can print CultureInfo.CurrentCulture.NumberFormat.PositiveInfinitySymbol to verify. It prints Infinity for me on Linux.
Description
System.Convert.ChangeType(...)
cannot convert positive or negative infinity tofloat
ordouble
in .NET 6/7/8.Reproduction Steps
Expected behavior
On all supported OSes and on all versions of .NET:
(float)Convert.ChangeType("∞", typeof(float))
should equalSingle.PositiveInfinity
(float)Convert.ChangeType("-∞", typeof(float))
should equalSingle.NegativeInfinity
(double)Convert.ChangeType("∞", typeof(double))
should equalDouble.PositiveInfinity
(double)Convert.ChangeType("-∞", typeof(double))
should equalDouble.NegativeInfinity
Actual behavior
They all throw on Linux.
Regression?
This has never worked in the past few major versions of .NET (Core). Didn't test EOL'd version of .NET (Core).
Known Workarounds
Special-case
"∞"
and"-∞"
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: