Why the compiler cannot decide the type

I'm just curious to know why do we need to add m or M for the decimal type?

Documentation says no implicit conversion

I think the compiler has enough information because we are declaring a keyword Decimal.

Can someone explain why the compiler cannot determine the value, should be considered as decimal, but not double.

+5
source share
1 answer

If you have such an operator

decimal x = 5.6;

the compiler first looks only at the right side of the task ( 5.6), determines its type ( double), and then checks whether the result can be assigned to the variable on the left side ( x).

x decimal, , double ( double decimal), .

( - - -. , .)

+5

All Articles