Closed
Description
Description
decimal.MaxValue
(79228162514264337593543950335) is representable within the range of double (as 7.9228162514264338E+28), however trying to cast a value back to decimal
it throws OverflowException
"Value was either too large or too small for a Decimal."
Reproduction Steps
double d = Decimal.ToDouble(decimal.MaxValue);
decimal converted = (decimal)(d);
Expected behavior
The operation succeeds and converted
== 7.9228162514264338E+28
Actual behavior
throws OverflowException
"Value was either too large or too small for a Decimal."
Regression?
No response
Known Workarounds
No response
Configuration
reproduces in net6.0 and net5.0. I haven't tried others.
Other information
No response