我在ext javascript中进行乘法时得到了错误的值 [英] i am getting wrong value while doing a multiplication in ext javascript

查看:88
本文介绍了我在ext javascript中进行乘法时得到了错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在我的项目中我使用的是ext java脚本。



在一个我的功能我正在与百万相乘



例如:7.1 * 1000000 = 7100000



所有数值工作正常,但只是它不适用于8.2和8.3。



我得到以下结果:



8.2 * 1000000 = 8199999.999999999但我想要8200000

8.3 * 1000000 = 8300000.000000001,我想要8300000



请帮助。

Hi All,

In my project i am using ext java script.

In one of my function i am doing multiplication with Million

Example : 7.1 * 1000000=7100000

All values are working fine but only it is not working for 8.2 and 8.3 only.

I am getting the below results:

8.2 * 1000000=8199999.999999999 but i want 8200000
8.3 * 1000000=8300000.000000001 ,I want 8300000

Please help on this.

推荐答案

你应该了解浮点数和浮点精度......

http://floating-point-gui.de/ [ ^ ]

还有一些JavaScript示例: http://www.w3schools.com/js/js_numbers.asp [<啊ref =http://www.w3schools.com/js/js_numbers.asptarget =_ blanktitle =新窗口> ^ ]
You should learn about floating points, and about the precision of floating points...
http://floating-point-gui.de/[^]
Also some samples for JavaScript: http://www.w3schools.com/js/js_numbers.asp[^]


这篇关于我在ext javascript中进行乘法时得到了错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆