Skip to content

map_range ZeroDivisionError #43

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

Merged
merged 1 commit into from
Jul 9, 2019
Merged

Conversation

inventhouse
Copy link
Contributor

Gracefully handle in_min == in_max: if input is lower or higher, return out_min or out_max, if input == in_min == in_max, return 50% of the output range; oh, and don't crash! Fixes issue #42

…rn out_min or out_max, if input == in_min == in_max, return 50% of the output range; oh, and don't crash
@ladyada ladyada requested a review from a team July 6, 2019 21:56
Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a bit to wrap my head around exactly what you were doing there, but it appears if the input range is 1 value and the output value is a range and x is that 1 value, you return halfway in between the output range which makes sense to me.

@makermelissa makermelissa merged commit d1ea1bb into adafruit:master Jul 9, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants