Yeah, while I do agree this change in behavior could be a major footgun for a few people, the vast majority of use cases for decimal should be unaffected. Decimal is usually used for business applications to the exclusion of double/float, not alongside them (the only doubles I've seen in my company's applications are just storing Lat/Long values for addresses, everything else uses decimal values).
Hell, on the rare occasion I've needed to use a decimal literal in code, I just use a decimal literal: don't do (decimal)0.1, just use 0.1m.
Exactly. If you want an actual decimal literal you should always write it as 1.2345m rather than converting it with the (decimal) prefix. The compiler refuses to accept a plain 1.2345 assigned to a decimal type so it’s not such a footgun as it may appear to some; though it might offer a better DX if the type of the literal was inferred from the thing you are trying to assign it to, that would no doubt have unintended consequences.
Fair enough, this is mostly what i do but since the runtime has been forgiving, i'll need to triple check that. I label all pure money fields as decimal, but am less confident for the ProductQuantity kind of fields. I typically use int for whole numbers but wouldn't be surprised if i used float occasionnally for quantities accepting decimals.
Even among floats, why double in particular? Why not single? Why not quad?
If practical, I'd give it either infinite precision or the type of whatever variable it's being stored into.
If that doesn't work and it has to be a specific type in all cases, making it a special decimal that converts to double without a warning would be a better baseline.
You suggestions seem like complex solutions to a non-existing problem. If you need a decimal literal, just use the “m”-suffix! Why introduce weird ambiguities? E.g what would be the type of the expression `1.0 / 3.0` in your system? It might not be assigned directly to a variable but could be an argument to an overloaded method.
The bottom line is you need to know if you are using a decimal or a double. If you think suffix-less literals are confusing, just make it a rule to always use a suffix.
Why is double the default for suffix-less numbers? Probably because it is a standard floating point type supported by all processors and languages. Seems like a reasonable default.
Hell, on the rare occasion I've needed to use a decimal literal in code, I just use a decimal literal: don't do (decimal)0.1, just use 0.1m.