Rescaling and limiting numbers: map() and constrain(). More...
Functions | |
| map (value, fromLow, fromHigh, toLow, toHigh) | |
| Rescales a number from one range to another. | |
| constrain (value, low, high) | |
| Limits a number to a range. | |
Rescaling and limiting numbers: map() and constrain().
| map | ( | value, | |
| fromLow, | |||
| fromHigh, | |||
| toLow, | |||
| toHigh ) |
Rescales a number from one range to another.
With whole numbers the result is a whole number, rounded towards zero as on an Arduino; with any float it is a float. Not clamped: use constrain().
| value | The number to rescale. |
| fromLow | Bottom of the range value is in. |
| fromHigh | Top of the range value is in. |
| toLow | Bottom of the new range. |
| toHigh | Top of the new range. |
| constrain | ( | value, | |
| low, | |||
| high ) |
Limits a number to a range.
| value | The number. |
| low | The smallest result. |
| high | The largest result. |