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

ASP.NET
aspnet_regsql不能在sql2005下使用的解决
.NET发送邮件
让.Net验证控件与自定义验证合作无间
给.Net程序员和WEB程序员建议:.Net篇
给.Net程序员和WEB程序员建议:WEB篇
Server Application Unavailable错误解决方法
ASP.NET AJAX:UpdatePanel控件
ASP.NET教程:Ref和Out关键字异同
组件Newtonsoft.Json实现object2json转换
ASP.NET教程:Control基类清理页面状态
ASP.NET入门教程:认识ASP.NET
ASP.NET入门教程:ASP.NET和ASP区别
ASP.NET入门教程:简单的ASP.NET页面
ASP.NET入门教程:服务器控件
ASP.NET入门教程:事件句柄
ASP.NET入门教程:Web表单
ASP.NET入门教程:Web表单维持对象的ViewState
ASP.NET入门教程:TextBox控件
ASP.NET入门教程:Button控件
ASP.NET入门教程:数据绑定

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 117 ::
收藏到网摘: 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.