---
title: "DecimalTest"
author: "kanglecjr"
date: "2009-07-06T10:32:13Z"
tags: ["C", "C#", "C++", "Linq"]
slug: "decimaltest"
draft: false
lastmod: "2009-07-06T10:32:13Z"
id: 420636
url: "https://kanglecjr.iteye.com/blog/420636"
---

```c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DecimalTest
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal x;
            double y;
            x = 3.14159265358979323m;

            x = x / 3;

            y = (double)x;

            Console.WriteLine("x={0}", x);

            Console.WriteLine("y={0}", y);

            Console.ReadKey();

        }
    }
}


```


注意：定义 Decimal 变量时， 数字后面应该带有 m 或 M。

结果：
<span style="color:green">x=1.0471975511965977433333333333
y=1.0471975511966</span>

[诚品服饰 英伦男装 无条件退换](http://s.click.alimama.com/a/qvYjdTCFlgg=-13358728)