将数字列表转换为正数和负数之间的百分比

Convert list of numbers to percent between positive and negative number

我有一个数字列表,例如 -17、-50、100、120、5、20 现在如何将这个系列转换为百分比。我在转换为百分比时遇到负数问题。例如我想将这些数字在 0 到 1 或 0% 到 100%

之间转换

你可以用最小值增加所有数字并将其转换为百分比。

-17+abs(-50) = 33
-50+abs(-50) = 0
100+abs(-50) = 150
120+abs(-50) = 170
5+abs(-50) = 55
20+abs(-50) = 70
After all result should convert like an this:
(number / max) * 100
(55 / 170) * 100 = 32.35%
(70 / 170) * 100 = 41.17%
(170 / 170) * 100 = 100%