哪个班级可以用来代表金钱? [英] What class to use for money representation?
本文介绍了哪个班级可以用来代表金钱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该使用哪个类来表示货币,以避免出现大多数舍入错误?
What class should I use for representation of money to avoid most rounding errors?
我应该使用十进制
,或简单的内置数字
?
Should I use Decimal
, or a simple built-in number
?
是否存在任何现有的钱
类可以支持我使用的货币换算吗?
Is there any existing Money
class with support for currency conversion that I could use?
我应该避免的任何陷阱吗?
Any pitfalls that I should avoid?
推荐答案
我假设您在谈论Python。
http://code.google.com/p/python-money/
使用Python处理货币和货币的基本原则-标题不言自明:)
I assume that you talking about Python. http://code.google.com/p/python-money/ "Primitives for working with money and currencies in Python" - the title is self explanatory :)
这篇关于哪个班级可以用来代表金钱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文