Guest User

Untitled

a guest
Oct 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. for (int i = n - 1; i >= 0; i--) {
  2.  
  3. int power16 = (int) Math.pow(16, n - i - 1);
  4.  
  5. //Convert input so that ABCDEF gets accounted for
  6. input = input.toUpperCase();
  7. String hex = "0123456789ABCDEF";
  8.  
  9. //Convert the charAt to String
  10. String digit = input.charAt(i) + "";
  11.  
  12. //Goes back to hex and finds the hex letter
  13. long newdigit = hex.indexOf(digit);
  14.  
  15.  
  16.  
  17. // Multiply each digit by its respective power of two
  18. output += newdigit * power16;
Add Comment
Please, Sign In to add comment