GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/java/405_Convert_a_Number_to_Hexadecimal.java at master · qiyuangong/leetcode Expand file tree/ Copy path405_Convert_a_Number_to_Hexadecimal.javaMore file actions 20 lines (18 loc) · 546 Bytes / Copy path405_Convert_a_Number_to_Hexadecimal.javaFile metadata and controls20 lines (18 loc) · 546 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import com.sun.corba.se.spi.orbutil.fsm.Guard.Result; class Solution { public String toHex(int num) { String hex_map = "0123456789abcdef"; if (num == 0) return "0"; String res = ""; // To avoid infinite loop caused by negative num while (num != 0 && res.length() < 8) { res = hex_map.charAt(num & 15) + res; num = num >> 4; } return res; } /* public String toHex(int num) { String hex = Integer.toHexString(num); return hex; } */ } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |