public static void main(String[] args) { for(int i=0; i<1; i++) { String foo = "alligator"; int j = (int) (foo.charAt(0) % Math.pow(2,7)) ; int k = (int) (foo.charAt(foo.length()/2) % Math.pow(2,7)) ; int h = (int) (foo.charAt(foo.length()-1) % Math.pow(2,7)) ; int result = (int)(((((j*128)+k)*128)+h) % Math.pow(2,20)); System.out.println( j + " " + k + " " + h + "\tResult " + i + ": " + result); } }