Instead of changing %d to %u, declare the variables as unsigned ints.