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.