```
class Solution(object):
def toHex(self, num):
"""
:type num: int
:rtype: str
"""
if(num==0):
return '0'
hextable=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
result=''
if(num!=0):
for i in range(0,8):
digits=hextable[num>>(i*4)&0xf]
result=digits+result
pos = 0
for i in range(0,7):
if(result[pos] == '0'):
pos+=1
return result[pos:]
```