Posted on June 18, 2021June 18, 2021 Description Submission class Solution { public: string toHex(int num) { if(num == 0) return "0"; const string s = "0123456789abcdef"; string ret; unsigned int n = num; for(; n > 0; n = (n >> 4)) { ret = s[n&15] + ret; } return ret; } }; By Bill0412 Easy LeetCode