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.