Clip out-of-bounds values