Given that Decimal.MaxValue = 79228162514264337593543950335m
Why does the next line give me 7922816251426433759354395034M in the Local window instead of 7922816251426433759354395033.5m as expected?
Decimal target = Decimal.MaxValue / 10m;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I suspect this is a compiler error, actually.
Here’s a short but complete program to show why I think that:
Output:
I’ll dig into the spec to see what guarantees are given.
EDIT: In the spec, section 7.18 claims:
That’s clearly not the case here. Hmm.
EDIT: I’ve submitted a bug to Microsoft Connect. We’ll see what happens to it.