D
Divick
Hi,
I have written a function which converts from ARGB1555 to RGBA5551
, i.e. changes the position of the msb to lsb by shifting the other
bits. The function is shown below, but I have doubt about the
correctness of this function.
In the operation below, I am using variable ARGB twice in the statement
and there is no sequence point in between those two uses. Thus the
answer is dependent upon the evaluation order of the statement. If ARGB
is shifted left and then used for the & operation then the answer will
not be correct. On my machine and compiler the answer seems right but I
still doubt this function.
void ARGB1555_to_RGBA5551(unsigned short &RGBA, unsigned short ARGB)
{
RGBA = ( (ARGB & (1L << 15)) > 0 ) | (ARGB << 1);
}
Am I right in my reasoning?
Thanks,
Divick
I have written a function which converts from ARGB1555 to RGBA5551
, i.e. changes the position of the msb to lsb by shifting the other
bits. The function is shown below, but I have doubt about the
correctness of this function.
In the operation below, I am using variable ARGB twice in the statement
and there is no sequence point in between those two uses. Thus the
answer is dependent upon the evaluation order of the statement. If ARGB
is shifted left and then used for the & operation then the answer will
not be correct. On my machine and compiler the answer seems right but I
still doubt this function.
void ARGB1555_to_RGBA5551(unsigned short &RGBA, unsigned short ARGB)
{
RGBA = ( (ARGB & (1L << 15)) > 0 ) | (ARGB << 1);
}
Am I right in my reasoning?
Thanks,
Divick