2
I spent a good time to solve this problem on my system. Solved? I did, but at some point it’s working (the subtraction value) = -0.0 and I have to give . replace('-', '') to show the user a positive value and this causes a lapse of change that is noticeable. All this is happening due to subtracting 0.1 from 2.8 results in 2.6999999999997. In my code it is already used . toFixed(1) and still won’t, I’ve even used Math.round().
After all, what is the point of subtracting 0.1 from 2.8 and resulting in that?
@Edit
I warn people that they "parachuted down". This issue is not duplicated either has nothing to do with the topic indicated, because my question was something very specific that, just looking at the code in the jsfiddle left in the comments, is that a solution can come to your problem.
Worse than I’ve ever read this topic and several others and, as I said, I’m already using .toFixed. I’ve cooled my head for a while and came up with some ideas. Thanks for trying to help.
– Wevelly Felipe
Nah. It wasn’t, I’ll leave it at that. I got beat xD
– Wevelly Felipe
The bid is to work with toFixed(n)... the sums and subtractions will always be exact.
– Sam
Worse than being correctly added and subtracted, it is not showing values beyond a decimal place (.toFixed(1)). The problem is that when it reaches 0.0, it’s showing -0.0 and I have to use replace to get that negative. What it looks like is like . toFixed was just masking and, from behind, the value is all broken and showing that negative. Unfortunately we can’t do everything the way we want.
– Wevelly Felipe
Something is wrong. In what situation
-
?– Sam
https://jsfiddle.net/h4dept29/ . The idea is what’s in this fiddle. Being that by my code there are several checks to see whether or not the user can increase or decrease. The fiddle is correct and does not appear -0.0, which I was surprised, because the code that is in the fiddle is identical. Now, I swear I can’t imagine what it could be. However, it already rules out the possibility of code error.
– Wevelly Felipe
I was able to replicate the error. Please click on the + until 0.0. https://jsfiddle.net/h4dept29/3/
– Wevelly Felipe