My JavaScript (ExtJs 4.1.0) code is:
Ext.getCmp('amount').setValue(Ext.num(Ext.getCmp('unite_price').getValue()) * Ext.num(this.getValue()));
It multiplies 3 with 0.048, and the result is 0.14400000000000002 instead of 0.144.
Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because of a rounding error in floating point numbers. This is a rather common phenomenon.
If you want 3 decimal points try to round to 3 decimal places.