double vs decimal

The following table lists the different between double type and decimal type.

Typedoubledecimal
Purposescitificfinancial
Interal representationbase 2base 10
SpeedFasterslower

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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.