Unsigned Integer with negative values used for texture write

In chapter 17 there are examples vectors of type uint2 being used with negative values on page 503:

output.write(color, location + uint2( 1, 0));
output.write(color, location + uint2( 0, 1));
output.write(color, location - uint2( 1, 0));
output.write(color, location - uint2( 0, 1));
output.write(color, location + uint2(-1, 1));
output.write(color, location - uint2(-1, 1));
output.write(color, location + uint2( 1,-1));
output.write(color, location - uint2( 1,-1));

Could you explain why this works or whether it is an error?

Cheers,
Eoin

That’s a print-out from the Metal debugger.

A uint will contain positive numbers only, so -1 will “wrap around” to the highest value. Here the highest value is 4294967295. When you add 10 to that, it wraps around again, as you can’t have a higher value.

Thanks for the explanation!