class Test1 { private static long filesize = 0; private static double percentage = 0.0; private static long offset = 0; private static long bytes = 0; public static void main(String[]args) { //filesize = 4205615302; //offset = 2147483648; bytes = 1048576; percentage = ((double)(offset + bytes) / (double)filesize)*100; System.out.println(percentage); } }