MSDN says:
“Without the suffix m, the number is treated as a double, thus generating a compiler error.”
What does the “M” in:
decimal current = 10.99M;
stand for?
Is it any different than:
decimal current = (decimal)10.99
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.
M makes the number a decimal representation in code.
To answer the second part of your question, yes they are different.
is the same as
Now for numbers larger than sigma it should not be a problem but if you meant decimal you should specify decimal.
Update:
Wow, i was wrong. I went to go check the IL to prove my point and the compiler optimized it away.
Update 2:
I was right after all!, you still need to be careful. Compare the output of these two functions.
The first returns
10.999999999999999999999but the seccond returns11Just as a side note, double will get you 15 decimal digits of precision but decimal will get you 96 bits of precision with a scaling factor from 0 to 28. So you can represent any number in the range ((-296 to 296) / 10(0 to 28))