Skip to content

Commit

Permalink
fix ScientificNotationNode when mantissa is 10, #613, phetsims/ph-sca…
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 21, 2020
1 parent 4607ed5 commit b44e8f9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/ScientificNotationNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ inherit( Node, ScientificNotationNode, {
mantissa = Utils.toFixedNumber( parseFloat( tokens[ 0 ] ), options.mantissaDecimalPlaces );
exponent = parseInt( tokens[ 1 ], 10 );

// If the mantissa is exactly 10, shift that power of 10 to the exponent.
// See https://github.com/phetsims/scenery-phet/issues/613
if ( mantissa === 10 ) {
mantissa = 1;
exponent += 1;
}

// Convert if a specific exponent was requested.
if ( options.exponent !== null ) {
mantissa = Utils.toFixedNumber( mantissa * Math.pow( 10, exponent - options.exponent ), Math.max( 0, options.mantissaDecimalPlaces ) );
Expand Down

0 comments on commit b44e8f9

Please sign in to comment.