cannawen / metric_units_reddit_bot

Reddit bot converting imperial units to metric units
https://www.reddit.com/user/metric_units
GNU General Public License v3.0
78 stars 34 forks source link

Improve rounding for small numbers #58

Closed cannawen closed 6 years ago

cannawen commented 6 years ago

metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.

Current behaviour:

  1. If an input number has a decimal place, the output number will have an equal amount of decimal places (i.e. 1.1111 miles -> 1.7881 km)
  2. Else if the input number is greater than 100 and it ends in a "0" then the output number will be rounded to within 5% accuracy
  3. Else the number will be rounded to within 3% accuracy

Problem: While this works the majority of the time, for some values this may lead to too much rounding.

Enhancement request: Find an algorithm that can handle these cases to round "appropriately."

Possible solution: In step 1 of the current algorithm, perhaps we can always round to 1% error, instead of matching the number of decimals? Open to any other ideas you can come up with.

See conversion_helper.roundConversions to get started!

Recommended reading: CONTRIBUTING.md (sections "Etiquette", "Work on an issue" and "Make a PR" are most important)

Recommended skills: Basic javascript & basic regular expressions

Estimated effort: 30-60 minutes

Comment below if you would like to take on this task!

cannawen commented 6 years ago

Marking as blocked on #61 because of potential merge conflicts

cannawen commented 6 years ago

https://www.reddit.com/r/metric_units/comments/73edn2/constructive_feedback_thread/do5x8cg

Looks like we should just rethink this whole rounding thing entirely. Closing issue, to be reopened with new requirements