Created
May 10, 2023 11:04
-
-
Save swapnildroid/ded3934d9ddd272cc064edd0e921e800 to your computer and use it in GitHub Desktop.
Range Conversion Java Kotlin Example
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
/** | |
* | |
* @param x | |
* @param inMin | |
* @param inMax | |
* @param outMin | |
* @param outMax | |
* @return | |
*/ | |
private long normalize(long x, long inMin, long inMax, long outMin, long outMax) { | |
long outRange = outMax - outMin; | |
long inRange = inMax - inMin; | |
return (x - inMin) *outRange / inRange + outMin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment