Skip to content

Commit

Permalink
correct rounding issue for phetsims/resistance-in-a-wire#179
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Oct 3, 2018
1 parent 3f5b987 commit bca97ec
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions js/accessibility/AccessibleSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,12 @@ define( function( require ) {
* @return {number}
*/
var correctRounding = function( newValue, currentValue, stepSize ) {
var decimalPlaces = Util.numberOfDecimalPlaces( stepSize );
var correctedValue = newValue;

var proposedStep = Util.toFixedNumber( Math.abs( newValue - currentValue ), decimalPlaces );
var proposedStep = Math.abs( newValue - currentValue );
var stepToFar = proposedStep > stepSize;

// it is possible that proposedStep will still be larger than the stepSize but only because of precision
// it is possible that proposedStep will be larger than the stepSize but only because of precision
// constraints with floating point values, don't correct if that is the cases
var stepsAboutEqual = Util.equalsEpsilon( proposedStep, stepSize, 1e-15 );
if ( stepToFar && !stepsAboutEqual ) {
Expand Down

0 comments on commit bca97ec

Please sign in to comment.