It’s because you’re doing integer division.
Divide by a double or a float, and it will work:
double scale = ( n / 1024.0 ) * 255 ;
Or, if you want it as a float,
float scale = ( n / 1024.0f ) * 255 ;
It’s because you’re doing integer division.
Divide by a double or a float, and it will work:
double scale = ( n / 1024.0 ) * 255 ;
Or, if you want it as a float,
float scale = ( n / 1024.0f ) * 255 ;