Files
30-seconds-of-code/snippets/num-to-range.md
Angelos Chalaris f6a215e9e3 Kebab file names
2023-04-27 22:00:06 +03:00

474 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Map number to range math round-leaves 2020-10-04T12:43:57+03:00 2021-04-05T18:25:46+03:00

Maps a number from one range to another range.

  • Return num mapped between outMin-outMax from inMin-inMax.
def num_to_range(num, inMin, inMax, outMin, outMax):
  return outMin + (float(num - inMin) / float(inMax - inMin) * (outMax
                  - outMin))
num_to_range(5, 0, 10, 0, 100) # 50.0