The "decimal" Data Type

This section describes the 'decimal' data type for floating-point values. 'decimal' uses a 128-bit storage size.

Comparing with Java, C# has a very interesting new date type called: decimal.

The "decimal" data type for floating-point values with a storage size that doubles the storage size of the "double" data type. See the storage size and precision range comparisons with "float", "double" and "decimal":

• float: 7 significant digits with a 32-bit storage size
• double: 15-16 significant digits with a 64-bit storage size
• decimal: 28-29 significant digits with a 128-bit storage size

The following code will show you this:

```// Decimals.cs

class Decimals {
public static void Main() {
float f;
double d;
decimal m;
f = 10.0f/3.0f;
d = 10.0d/3.0d;
m = 10.0m/3.0m;
System.Console.WriteLine("Float 10/3 = {0}", f);
System.Console.WriteLine("Double 10/3 = {0}", d);
System.Console.WriteLine("Decimal 10/3 = {0}", m);
}
}
```

Output:

```Float 10/3 = 3.333333
Double 10/3 = 3.33333333333333
Decimal 10/3 = 3.3333333333333333333333333333
```

Last update: 2015.