How to reverse a long sum without loosing the first digit after the sum reverse? : I've completed a program where it reverse long sum's, but for some reason when I try to reverse the sum of two long values it drops the first number. The first number I use is 1234567890000000000 and the second 1234567890. When I do the calculations the total adds to 1234567891234567890 and suppose to reverse to 0987654321987654321. Instead my program drops the zero and return a result of 987654321987654321. Is my while loop math off? When you try smaller integers like 567 and 456 = 1023 reversed 3201. I think when a zero is at the end of any value it reverse incorrectly.

    import java.math.*;
    import java.util.Scanner;
    import java.lang.*;

    public class Exercise3
    {	 
	    public static void main(String args[])
	 
	    {
		
		   Scanner sc = new Scanner(System.in);
		
		   System.out.println("Enter first number: ");
		
		   long n1 = sc.nextLong();
		
		   System.out.println("Enter second number: ");
		
		   long n2 = sc.nextLong();
		
		   long sum = n1+n2;
		
		   long reverseSum = 0;
		
		   long rem;
		
		   while(sum != 0)
		   {
			rem = sum % 10;
			reverseSum = reverseSum * 10 + rem;
			sum = sum / 10;
		   }
		
	       System.out.println("The reversed sum is " + reverseSum);
	 
	     } 
   }
