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.

相关文章:

  • 2021-06-01
  • 2022-12-23
  • 2021-06-12
  • 2021-07-07
  • 2022-12-23
  • 2021-04-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-10-14
  • 2021-11-07
  • 2021-05-12
相关资源
相似解决方案