I just need to take two decimals of a number with the toFixed (2) method and for that I have to convert the numbers to parseFloat because otherwise the toFixed method fails me. The problem is that they give me wrong numbers and I do not know why.
var x=0;
var y=0;
var T=127.76;
var c=63.88;
var ci=110.64;
Without using parseFloat and toFixed;
var x1=x+ci;//110.64809081046089
var y1=y-c;//-63.882705014737745
var x2=x1+c;//174.53079582519862
var y2=y1+ci;//46.76538579572314
When using parseFloat and toFixed the result misses;
var x1=x+ci;//110.64809081046089
x1=parseFloat(x1);//110.64809081046089
x1=x1.toFixed(2);//110.65
var y1=y-c;//-63.882705014737745
y1=parseFloat(y1);//-63.882705014737745
y1=y1.toFixed(2);//-63.88
Here already calculates me wrong operations
var x2=x1+c;//110.6563.882705014737745 Y DEBERIA DAR 174.53079582519862
x2=parseFloat(x2);
x2=x2.toFixed(2);
var y2=y1+ci;//-63.88 Y DEBERIA DAR 46.76538579572314
y2=parseFloat(y2);
y2=y2.toFixed(2);
I do not understand why these results are wrong.