Please observe the following code:


Code:
*(image->data + j + (i * image->width)) = (1/sqrt(2.0)) * sum;
Code:
*(image->data + j + (i * image->width))
This left hand side points to a memory space of type 'unsigned char'.

Code:
sum
sum is a variable of type float.


My issue is I need the left hand side to store the number from the right hand side in the 'unsigned char' data space.

This is because the right handside values are in the range 0-255. Therefore I do NOT need the extra space that int offers.

But the problem is the left handside just inteprets the number from the right hand side as an ASCII code. This I don't want to happen.

I want to store actual number i.e. if I get 255, then store 255 on the left hand side.

I've tried casting the right handside, but no luck.

I'm sure I'm missing some fundamental point here.