简体   繁体   English

javascript float或double来处理货币/货币值

[英]javascript float or double for handling currency/money value

Which type to use (float or double) for handling currency/money? 使用哪种类型(浮点型或双精度型)来处理货币/货币? At the moment I am using float for handling currency/money. 目前,我正在使用float来处理货币/金钱。 I searched through the net, but found nothing. 我在网上搜索,但一无所获。 I know this is a question that includes debate which is not allowed, but I need some explanation for me to decide. 我知道这是一个不允许辩论的问题,但是我需要一些解释才能决定。

Thanks 谢谢

There is only one type of number in javascript . javascript中只有一种数字 So you don't really have a choice. 因此,您实际上别无选择。

All numbers in JavaScript are 64-bit floating point numbers, ie double. JavaScript中的所有数字都是64位浮点数,即double。

See the following links for more information: 有关更多信息,请参见以下链接:

http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference

http://www.crockford.com/javascript/survey.html http://www.crockford.com/javascript/survey.html

You don't have a choice in regard to the way your numbers are stored. 关于号码的存储方式,您别无选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM