Problem description
If I ask you, 4330.61 times 100 equals how much, I guess you must say to me: "Must be 433061" Ah!
Yes, I am the same answer, come on, let's see what the browser says, like
The browser told me he was wrong.
Theodoros The browser tells me that he is wrong, if the customer to calculate money, the customer does not have the opinion ....
Why? Computer calculation is not as good as my own mental arithmetic!!!!
If you want to know what the reason, you see =>js floating point accuracy problem of the past life?
Solutions
;(function){functionMathService (){This.add=functionA, b) {var c, D, E;try {c = a.tostring (). Split (".") [1].length; }catch (f) {c =0; }try {d = b.tostring (). Split (".") [1].length; }catch (f) {d =0; }return e =Math.pow (10,Math.max (c, D)), (This.mul (A, E) +This.mul (b, E))/E; }This.mul=functionA, b) {var C =0, D = a.tostring (), E = b.tostring ();try {c + = D.split (".") [1].length; }catch (f) {}try {c + = E.split (".") [1].length; }catch (f) {}ReturnNumber (D.replace (".","")) *Number (E.replace (".","")) /Math.pow (, c); }this.sub=functionA, b) {var c, D, E;try {c = a.tostring (). Split (".") [1].length; }catch (f) {c =0; }try {d = b.tostring (). Split (".") [1].length; }catch (f) {d =0; }return e =Math.pow (10,Math.max (c, D)), (This.mul (A, E)-This.mul (b, E))/E; }this.div=functionA, b) {var c, d, E =0, F =0;try {e = a.tostring (). Split (".") [1].length;} catch (g) {} try {f = b.tostring (). Split (".") [1].length;} catch (g) {} return c = number (a.tostring (). Replace (".", "")), d = number (b.tostring (). Replace (".", ""), This.mul (C/D, Math.pow (f-e));}} window.mathservice=New MathService ()}) (window);
Come on, use it.
Image.png
Ok! Finish your homework!!!
Little Maple learns humor
Links: https://www.jianshu.com/p/c3374517b976
Source: Pinterest
The copyright of the book is owned by the author, and any form of reprint should be contacted by the author for authorization and attribution.
Bill: JS Mathematical calculation accuracy correction