You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.
The problem is that first num is divided by divisions and only then multiplied by i. Javascript calculates with floats and thus rounds in sometimes unexpected ways. Change the order (first multiply, then divide) and it's gonna be allright. (Or round the result before parseInting.)
// For first iteration, don't divide.
var auxNum = i == divisions ? num : num / divisions * i;
then...
// Preserve as int if input was int
var newNum = parseInt(auxNum);
// Preserve float if input was float
if (isFloat) {
newNum = parseFloat(auxNum).toFixed(decimalPlaces);
}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
24.0 works, 23 works and 25 works but 24 gets stuck at 23. Interestingly, the same issue can be replicated at 3, 6, 12, 24, 48 and 96...
I tried a few of the earlier posted solutions but still doesn't work.
The text was updated successfully, but these errors were encountered: