我应该使用什么数据类型在C#中重新present钱?
在C#中,我应该用什么数据类型来重新present货币金额?十进制?浮动?双?我要好好考虑:precision,四舍五入等
In C#, what data type should I use to represent monetary amounts? Decimal? Float? Double? I want to take in consideration: precision, rounding, etc.
使用System.Decimal$c$c>:
十进制值类型重新presents
十进制数从正面
79,228,162,514,264,337,593,543,950,335
至负面
79,228,162,514,264,337,593,543,950,335。
十进制值类型是合适的
对于需要财务计算
大量显著积分
和小数位且没有舍入
错误。的十进制类型不
消除了舍入的需要。
相反,它最大限度地减少由于错误
四舍五入。
The Decimal value type represents decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335. The Decimal value type is appropriate for financial calculations requiring large numbers of significant integral and fractional digits and no round-off errors. The Decimal type does not eliminate the need for rounding. Rather, it minimizes errors due to rounding.
System.Single
(浮动
)也不 System.Double
(双击
)是 precise足够能够重新$的p $ psenting高precision浮点数没有舍入误差。
Neither System.Single
(float
) nor System.Double
(double
) are precise enough capable of representing high-precision floating point numbers without rounding errors.