当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > .NET数值类型的精度

ASP.NET
深入理解__doPostBack 客户端调用服务端事件
asp.net(c#)利用构造器链的代码
asp.net Repeater绑定时使用函数
asp.net下linkbutton的前后台使用方法
ASP.NET编程中经常用到的27个函数集
asp.net高效替换大容量字符实现代码
asp.net(c#) ubb处理类
ASP.NET中的跳转 200, 301, 302转向实现代码
C#中的委托和事件学习(续)
asp.net网站安全从小做起与防范小结
asp.net 网页编码自动识别代码
asp.net HttpWebRequest自动识别网页编码
asp.net中调用winrar实现压缩解压缩的代码
dz asp.net论坛中函数--根据Url获得源文件内容
.NET 扩展实现代码
用Jquery访问WebService并返回Json的代码
asp.net(c#)判断远程图片是否存在
asp.net保存远程图片的代码
Asp.Net类库中发送电子邮件的代码
ASP.NET表单验证方法详解

ASP.NET 中的 .NET数值类型的精度


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 133 ::
收藏到网摘: n/a


float类型占32bit空间,只有7位精度,下面的程序
public class FloatPrecision
{
public static void Main()
{
Console.WriteLine((int)123456789F);
}
}
输出结果为123456792.
double占64bit空间,15~16位精度,下面的程序
public class DoublePrecision
{
public static void Main()
{
Console.WriteLine((long)123456789012345678D);
}
}
输出结果为123456789012345680
decimal占128bit空间,28位精度,MSDN中描述如下:
This type is useful for applications (such as accounting) where rounding errors must be avoided.