Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0028 double vs decimal

The following table lists the different between double type and decimal type. Type double decimal Purpose scitific financial Interal representation base 2 base 10 Speed Faster slower using System; class Program { static void Main(string[] args) { decimal d = 1; decimal d2 = 0.1M; Console.WriteLine(d - d2*10); } } The output: 0.0