Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reversing Numbers
#1
This method will return the reverse of a non-zero number
[code2=java]public static long ReverseNumber(long number)
{
int reversedNumber = 0;
while (number > 0)
{
reversedNumber *= 10; //Shift over the reversed number
reversedNumber += (int)(number % 10); //Add on the end of the submitted number
number/=10;
}

return reversedNumber;
}[/code2]
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Reversing Numbers - by brandonio21_phpbb3_import2 - 08-06-2012, 11:28 PM
Re: Reversing Numbers - by WitherSlayer - 01-05-2013, 12:48 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)