I found this handy little post: http://www.geeksforgeeks.org/archives/527 explaining how to reverse the digits of a number. I'm still not completely sure how it works, and I'll be reading through it again to get my head around it, but it's helpful all the same.