Created
January 8, 2019 14:55
-
-
Save squalvj/a9462afb5291c7755391b2906edb67fc to your computer and use it in GitHub Desktop.
Algorithm calculate third number based on min max and convert them to percent
This file contains 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
// basic | |
var max = 250 | |
var min = 50 | |
var input = 65 | |
var percent = ((input - min) * 100) / (max - min) | |
// a little longer | |
var range = max - min | |
var correctedStartValue = input - min | |
var percentage = (correctedStartValue * 100) / range |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment