What does M mean just after a number?

  • Thread starter Thread starter tundra999
  • Start date Start date
T

tundra999

Such as this:

return base.CalculatePrice() * 0.9M;

What data type does the 'M' stand for? I can't find a listing of these
shorthand notations anywhere.

Thanks,
Tom
 
Such as this:

return base.CalculatePrice() * 0.9M;

What data type does the 'M' stand for? I can't find a listing of these
shorthand notations anywhere.

Thanks,
Tom

decimal.
 
Such as this:

return base.CalculatePrice() * 0.9M;

What data type does the 'M' stand for? I can't find a listing of these
shorthand notations anywhere.

Thanks,
Tom
They are called type suffixes.

Integer type suffixes are: U, L, UL, LU, u, l, ul, lu, Ul, uL, Lu, lU
where U/u = unsigned and L/l = long. Lowercase l is not recommended
unless you want to obfuscate your source code.

Real type suffixes are: F, D, M, f, d, m where F/f = float, D/d =
double. M/m = Decimal

rossum
 
Thanks I appreciate it. But if 'M' means Decimal, then what does 'D'
stand for? Are both 'D' and 'M' decimal? If so why have both? Is
there a difference?

Thanks,
Tom
 
Thanks I appreciate it. But if 'M' means Decimal, then what does 'D'
stand for? Are both 'D' and 'M' decimal? If so why have both? Is
there a difference?

From the post you just replied to:

[...]
Real type suffixes are: F, D, M, f, d, m where F/f = float, D/d =
double. M/m = Decimal

I think that pretty much sums it up.
 
Thanks I appreciate it. But if 'M' means Decimal, then what does 'D'
stand for? Are both 'D' and 'M' decimal? If so why have both? Is
there a difference?

Thanks,
Tom
The L, U, F, and D suffixes are used in C, C++, Java and probably
elsewhere. When C# introduced the Decimal type the D suffix was
already in use for Double so they picked M instead.

rossum
 
To be more clear, M = Money, which is typcically what the type is used for,
becuase it avoids the round-off errors you get when using floating-point
representations like float and double. If you want to have numbers that are
quick to compute and can be super tiny or astronomically large but don't
care if some error is introduced (typically applications like games,
simulations, etc.) then use a float/double. If your want #'s in a
"reasonable" ranage but care about more presision and less error, then use a
decimal/money. (SQL also supports a similar type and it should always be
used for monetary amounts.)

http://en.csharp-online.net/ECMA-334:_11.1.7_The_decimal_type

m
 
MBR said:
To be more clear, M = Money, which is typcically what the type is used for

<snip>

I believe that while M=Money is a good way of remembering it, Peter
Golde recalls it being picked just as the next appropriate character
from "decimal". I suspect that there'll never be any proof either way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top