microsoft / calculator

Windows Calculator: A simple yet powerful calculator that ships with Windows
MIT License
29.54k stars 5.35k forks source link

Precision is lost when switching conversions #177

Closed jsoref closed 4 years ago

jsoref commented 5 years ago

Describe the bug

While general math does not lose precision (see #119), unit conversions do.

From my perspective, this is a bug, but I suspect fixing this would make it a feature request. I'm filing it as a bug because the information required here and the information I have available more closely fit the bug filing form.

Steps To Reproduce

  1. Open Calculator
  2. Tap ≡
  3. Tap Power
  4. Tap Kilowatts (top unit -- this computer is en-US not en-GB where the default is Watts)
  5. Step 1: (‎3/‎7/‎2019 11:10:37 AM) User left click on "Six (button)" in "Cal"
  6. Step 2: (‎3/‎7/‎2019 11:10:38 AM) User left click on "Zero (button)" in "Cal"
  7. Step 3: (‎3/‎7/‎2019 11:10:41 AM) User left click on "Converts into ‪3.412141‬ BTUs/minute (text)" in "Cal"
  8. Step 4: (‎3/‎7/‎2019 11:10:42 AM) User left click on "Input unit (combo box)" in "Cal"
  9. Step 5: (‎3/‎7/‎2019 11:10:43 AM) User left click on "Foot-pounds/minute (text)" in "Cal"
  10. Step 6: (‎3/‎7/‎2019 11:10:46 AM) User left click on "Input unit (combo box)" in "Cal"
  11. Step 7: (‎3/‎7/‎2019 11:10:47 AM) User left click on "BTUs/minute (text)" in "Cal"
  12. Step 8: (‎3/‎7/‎2019 11:10:49 AM) User left click on "Converts into ‪59.9999972482667‬ Watts (text)" in "Cal"
  13. Step 9: (‎3/‎7/‎2019 11:10:50 AM) User left click on "Steps Recorder - 1 running window (button)"

Expected behavior

Ideally it would still show 60 Watts in the top field. This would require unit conversions to cooperate with the ratpack

Screenshots image image

Note: this was recorded w/ psr.exe, so I have screen shots for all of the recorded steps (and I could trivially re-record w/ the missing initial setup steps.

Device and Application Information (please complete the following information):

Additional context

MicrosoftIssueBot commented 5 years ago

This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.

grochocki commented 5 years ago

Thanks for the report! I really appreciate your thoroughness when filing this bug. I was able to verify this across other converters as well, including Speed and Pressure.

jsoref commented 5 years ago

Fwiw, I've started stepping through how to do this here: https://github.com/jsoref/Microsoft-calculator/commits/issue-177

If someone familiar w/ RAT/PRAT could give me some pointers, I think this might be somewhat close to something. (I haven't touched the tests, nor have I fed this code to a compiler.)

HowardWolosky commented 5 years ago

If someone familiar w/ RAT/PRAT could give me some pointers, I think this might be somewhat close to something. (I haven't touched the tests, nor have I fed this code to a compiler.)

cc @joshkoon