Last active
March 27, 2019 01:34
-
-
Save peacefixation/1c0c963670cf05067ef1989bf62136fc to your computer and use it in GitHub Desktop.
Scale a number to a new range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stats.stackexchange.com/questions/281162/scale-a-number-between-a-range | |
function scale(n, oldMin, oldMax, newMin, newMax) { | |
return ((n - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment