Why is decimal not a primitive type?

.net, c#, vb.net

Solution

Although not a direct answer, the documentation for `IsPrimitive` lists what the primitive types are:

http://msdn.microsoft.com/en-us/library/system.type.isprimitive.aspx

A similar question was asked here:

http://bytes.com/topic/c-sharp/answers/233001-typeof-decimal-isprimitive-false-bug-feature

Answer quoted from Jon Skeet:

The CLR doesn't need to have any intrinsic knowledge about the decimal type - it treats it just as another value type which happens to have overloaded operators. There are no IL instructions to operate directly on decimals, for instance.

To me, it seems as though `decimal` is a type that must exist for a language/runtime wanting to be CLS/CLI-compliant (and is hence termed "primitive" because it is a base type with keyword support), but the actual implementation does not require it to be truly "primitive" (as in the CLR doesn't think it is a primitive data type).

Problem

Why is `decimal` not a primitive type? ``` Console.WriteLine(typeof(decimal).IsPrimitive); ``` outputs `false`. It is a base type, it's part of the specifications of the language, but not a primitive. What primitive type(s) do represent a `decimal` in the framework? An `int` for example has a field `m_value` of type `int`. A `double` has a field `m_value` of type `double`. It's not the case for `decimal`. It seems to be represented by a bunch of `int`s but I'm not sure. Why does it look like a primitive type, behaves like a primitive type (except in a couple of cases) but is not a primitive type?

Original source

Related problems