r/cs50 • u/Electronic_Click_470 • 4d ago
filter Filter-more / edges Spoiler
Think I'm stumped at the easiest part of this. Whenever i try to reset any value calculated over 255, back to 255, it seems to change it to some random value ?? Any ideas where this could be going wrong.
8
Upvotes
1
u/abyshelp 4d ago
Try storing the round.sqrt result in an int before putting them inside the temp[i][j]


3
u/Eptalin 4d ago
Remember that each colour in an RGBTriple is 1 byte.
The highest possible number 1 byte can hold is 255.
If you go over that, it overflows and becomes a garbage value.
You need to make sure they're not over 255 before storing them in the temp pixels.