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))
This is to mirror the change in V2:
If any of the values inside the tuple for the
to
paramenter are floats, thenmicrobit.scale()
will return a float, otherwise it will return an integer.For example: