Hi i need to know how can i achiveve a normalize for ranged values for example
i have range 2304 to 0
and i want to know 1743 value in the range of 0 to 1
Hi i need to know how can i achiveve a normalize for ranged values for example
i have range 2304 to 0
and i want to know 1743 value in the range of 0 to 1
float normal = 1743 / 2304;
I can never remember if you need to cast ints to floats in operations like this so probably safer to to avoid decimals being truncated in the division of ints.
float normal = (float)1743 / (float)2304;
or for short
float normal = 1743f / 2304f;
Can someone clarify this?
Mathf.InverseLerp is what you want:
Mathf.InverseLerp(0, 2304, 1743)
Yeah i guess this is better as it deals with values beyond the range.
thanks very much