Where are you getting this number? Why are you only interested in the last 6 digits? What if the number is only a 3 digit number?
Well the fact that the OP used the variable name serialNumber made me think it was exactly that, a serial number, and that they are of a specific length in his world. Often, the sections of serial numbers mean something: perhaps in his case the last 6 digits are the actual sequence number and that's what he needs to know for his purpose. Maybe the part before that is the factory and line number or something.
Thanks for the replies. As mentioned earlier I'm interested in only the last six digits of the number which form a serial number. I think I understand now your suggestions. So by using % (modulo) it divides the number until it can't be divided any more then returns the remainder.