Scale numbers to be <= 255?

前端 未结 13 2354
生来不讨喜
生来不讨喜 2021-02-05 18:39

I have cells for whom the numeric value can be anything between 0 and Integer.MAX_VALUE. I would like to color code these cells correspondingly.

If the val

13条回答
  •  青春惊慌失措
    2021-02-05 19:07

    In general (since it's not clear to me if this is a Java or Language-Agnostic question) you would divide the value you have by Integer.MAX_VALUE, multiply by 255 and convert to an integer.

提交回复
热议问题