I use a simple uint8_t to store a real value between 0.0 and 1.0, with 0 being mapped to 0.0 and 255 being mapped to 1.0, and linear interpolation in-between.
Obviously i can multiply this numbers with the following procedure:
- divide them / 255.0f
- multiply the resulting floats
- convert the result back to the uint8-range (uint8_t)(result * 255.0f)
However i wonder if there exists an easier way which produces the same result without involving the float conversion (i.e. some black magic bit fiddling or shifting)?
Any help would be appreciated!