Use record. Please notice corner cases: n < 0; n = -2147483648(the smallest negative int).