-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScientificNotationNode #613
Comments
Fixed in the above commit. This problem occurs only when the mantissa is exactly 10, so the fix is specific to that value. Some tests:
|
Reopening. After further digging, I discovered that this bug was introduced by @jessegreenberg in bfa1874 on 9/20/17. Reverting that commit yields the correct result:
There's no GitHub issue referenced in the commit. @jessegreenberg do you recall why that change was made? |
Commit bfa1874 actually does reference #334 which describes:
|
Thanks @jessegreenberg -- the issue number didn't show up as a link in WebStorm's "Show History", so I missed it. The change I made in 65aa972 doesn't affect the goal of bfa1874. So I'll leave things as is and re-close. |
As discovered in phetsims/chipper#946, there are TODOs in the code referring to this issue. Reopening. |
Here's the remaining TODO: // Convert to a string in exponential notation, where the mantissa has 1 digit to the left of the decimal place.
//TODO https://github.com/phetsims/scenery-phet/issues/613 toExponential uses Number.toFixed, which doesn't round the same on all platforms
const exponentialString = value.toExponential( options.mantissaDecimalPlaces ); Per @kathy-phet in dev meeting, no plans to address this anytime soon, so unassigning. |
In phetsims/dot#113, @zepumph and I changed the implementation of Utils.toFixed to use https://github.com/MikeMcl/big.js, which is described as "A small, fast JavaScript library for arbitrary-precision decimal arithmetic." @pixelzoom can you please check on the status of this TODO after that change? Please zoom consult with me and or @zepumph at your discretion. |
Running the tests in #613 (comment), this appears to be resolved. So I deleted the associated TODO comments, and will close this issue. |
Discovered in phetsims/ph-scale#173.
Example:
So
9.952541657737637e-8
is displayed as "10.0 x 10-8", when it should be "1.0 x 10-7".This only occurs when the mantissa is exactly 10. And in that case, that power of 10 needs to be shifted to the exponent.
This will affect all sims that use
ScientificNotationNode
, which currently includes: blackbody-spectrum, coulombs-law, gravity-force-lab, gravity-force-lab-basics.The text was updated successfully, but these errors were encountered: