System.decimal precision

About Decimal value and precision:
Decimal number Decimal System. Decimal 16bytes valus:
-79228162514264337593543950335
to 
79228162514264337593543950335
 
Precision:  
max precision is  ±1.0 × 10e-28
but maximum support only  29 significant digits
(Same with 32 bit operate system )

we can verify use program.
       "static void Main(string[] args)
        {
            System.Console.WriteLine("decimal max:  {0}, min:  {1}",System.Decimal.MaxValue, System.Decimal.MinValue);
            System.Console.ReadLine();
        }"
out put is :
decimal max:  79228162514264337593543950335, min:  -79228162514264337593543950335
what i need  ±1.0 × 10e−28  is the precision
we can verify use program.
  "System.Decimal a, b,sum =0;
   a = 1.1111111111111111111111111111111111111111111111111111111111111m; //60
   b = 1.2222222222222222222222222222222m; //30
  sum = a + b;
   System.Console.WriteLine("decimal presion:  {0} \n",sum);"
 
decimal presion:  2.3333333333 3333333333 33333333  //  28
so the precision  is   ±1.0 × 10e−28 .

posted on 2012-08-30 09:40  子虚乌有  阅读(531)  评论(0)    收藏  举报