I'm working on pset4 filter(less) and have a question regarding limiting the RGB value to 8 bits. I'd like to know what happens when a value of more than 8 bits is stored in BYTE (uint8_t). Initially, I thought that this would limit the value to 255, but clearly, I'm wrong.
BYTE sepiaRed = round(.393 * image[i][j].rgbtRed + .769 * image[i][j].rgbtGreen + .189 * image[i][j].rgbtBlue);
BYTE sepiaGreen = round(.349 * image[i][j].rgbtRed + .686 * image[i][j].rgbtGreen + .168 * image[i][j].rgbtBlue);
BYTE sepiaBlue = round(.272 * image[i][j].rgbtRed + .534 * image[i][j].rgbtGreen + .131 * image[i][j].rgbtBlue);
The error messages I'm getting are:
helpers.c:34:29: runtime error: 274 is outside the range of representable values of type 'unsigned char'
helpers.c:35:31: runtime error: 277 is outside the range of representable values of type 'unsigned char'
On a side note, if this causes 8-bit unsigned integer overflow, according to wraparound, shouldn't I get 19 (255 + 19) and 22 (255 + 22) instead of 274 and 277?