react-range icon indicating copy to clipboard operation
react-range copied to clipboard

Warning emitted by isStepDivisible due to floating point value mismatch

Open forestlovewood opened this issue 5 years ago • 3 comments

I just noticed that if you try and create a Range control which has the following props <Range step={0.1} min={0.1} max={50} ... /> it will emit a The difference of max and min must be divisible by step warning.

This appears to be because (50 - 0.1) / 0.1 equals 498.99999999999994 in JavaScript, but the expression parseInt(res.toString(), 10) actually just returns 498. Most calculators would return 499 for both.

Thank you!

forestlovewood avatar Nov 22 '20 12:11 forestlovewood

Ah, maybe we should just remove that warning,

tajo avatar Nov 25 '20 07:11 tajo

+1 remove it

AbeCole avatar Jul 15 '21 16:07 AbeCole

@tajo I fixed this problem in PR above.

dgershun avatar Jul 28 '21 16:07 dgershun