material-range-bar icon indicating copy to clipboard operation
material-range-bar copied to clipboard

float number precision loss when the range is large.

Open VaibhavOPTIX opened this issue 8 years ago • 2 comments

Since all the methods like setTickStart(), setTickEnd(), setTickInterval(),setRangePinsByValue() and the others all take float values, when the range is large the numbers loose precision and hence loose data. Please take note on this issue

VaibhavOPTIX avatar Mar 30 '16 12:03 VaibhavOPTIX

Hi, please use this code to fix setRangePinsByValue() in RangeBar:

mLeftIndex = Math.round((leftPinValue - mTickStart) / mTickInterval);
mRightIndex = Math.round((rightPinValue - mTickStart) / mTickInterval);

instead of (incorrect)

mLeftIndex = (int) ((leftPinValue - mTickStart) / mTickInterval);
mRightIndex = (int) ((rightPinValue - mTickStart) / mTickInterval);

Hope it will helpful.

evgentset avatar Jun 28 '16 13:06 evgentset

thanx..i ended up doing just that. sorry for not posting the same earlier

VaibhavOPTIX avatar Jun 29 '16 04:06 VaibhavOPTIX