Transform the number from one numeric range to another
This formula helps to convert the number to different numeric range
Let the following denote:
S: input score
Smin: min score
Smax: max score
Gmin: min gpa
Gmax: max gpa
G: output gpa
Then your formula is:
G=(S−Smin)⋅(Gmax−Gmin)Smax−Smin+Gmin
For example:
s = 1236;
smin = 10;
smax = 2000;
gmax = 400;
gmin = 1;
g = (s - smin)*(gmax-gmin)/(smax-smin) + gmin = 246;
So, the number 1236
was converted from [10...2000] range to [1...400] range and now equals 246
.
PreviousHow to set Kafka offsets of a consumer group to a predefined list for all partitions at once?NextUseful resources
Last updated