Conversion between primitive types is trivial in high-level languages like C# as you can use the cast operator, optionally surrounded with checked or unchecked to force the integer overflow semantics. At CIL level the conversion is less trivial, involving the choice of no fewer than 27 different op-codes...
I've been writing a fair bit of Reflection.Emit code recently, and along the way have developed quite a number of extension methods for the ILGenerator class to handle the complex semantics of some seemingly trivial operations , and choose the most efficient op-codes (e.g. when can the short forms...
Some languages such as C# let you treat the System.Decimal type as an integral type most of the time, even having the keyword decimal , and will let you declare constant fields of the type under some circumstances. However, decimal isn't a primitive type in the same way as the other numerics, and...