Zend_Currency 值以美分代替美元
我正在使用 Zend_Currency 并希望以美分存储值(而不是美元),因为系统的其他部分以美分工作。所以,我想初始化和检索 Zend_Currency 对象的值(以美分为单位),有没有办法以这种方式配置 Zend_Currency ?
我知道当我检索该值时我可以除以 100,但我不知道当/如果我们需要国际化时这会有多兼容。 IE。 所有货币都是100“分”单位兑“美元”吗?
I am using Zend_Currency and would like to store the values in cents as (opposed to to dollars) due to other parts of the system that work in cents. So, I would like to initialise and retrieve values for Zend_Currency objects in cents, is there a way to configure Zend_Currency this way?
I am aware I could just divide by 100 when I retrieve the value, but I don't know how compatible this would be when/if we need to internationalize. ie. Are all currencies 100 "cent" units to the "dollar".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有货币的单位都是“美元”100“分”吗?
不是。
虽然大多数都是这样,但也有少数货币的基数为“5”或“1000”,或者没有小数点全部。
来源:http://en.wikipedia.org/wiki/List_of_circulate_currencies
您应该使用 Zend 货币存储原始值并让它为您进行转换。
注意:My_Currency_Exchange() 是我创建的一个虚拟类,它看起来像这样:
输出:
浮点(100.5)浮点(261.0387)
Are all currencies 100 "cent" units to the "dollar"?
No.
Although most do, there are a few that have a base of '5' or a base of '1000' or no decimal at all.
source: http://en.wikipedia.org/wiki/List_of_circulating_currencies
You should be using Zend Currency to store the raw value and let it do conversions for you.
Note: My_Currency_Exchange() is a dummy class I've created, it looks like this:
output:
float(100.5) float(261.0387)