Skip to content
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

microbit.scale() to return a float if the arguments for the to parameter are floats. #770

Closed
microbit-carlos opened this issue Sep 26, 2022 · 1 comment
Milestone

Comments

@microbit-carlos
Copy link
Collaborator

microbit-carlos commented Sep 26, 2022

This is to mirror the change in V2:

If any of the values inside the tuple for the to paramenter are floats, then microbit.scale() will return a float, otherwise it will return an integer.

For example:

# This Celsius to Fahrenheit conversion will return a float
this_will_return_float = scale(value, from=(0, 100), to=(32.0, 212.0))

# This conversion between the accelerometer output to a 1 byte range will return an integer
this_will_return_int = scale(accelerometer.get_x(), from_=(-2000, 2000), to=(0, 255))
@microbit-carlos microbit-carlos added this to the Version 1.1 milestone Sep 26, 2022
@dpgeorge
Copy link
Member

Implemented in 8333ac9

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

No branches or pull requests

2 participants