value. Return a string with its hexadecimal (base-16) notation.
- Digits 10 through 15 are written as lowercase letters a–f.
- There must be no leading zeros; the number 0 itself is written as "0".
- A negative number is written in two's complement: all 32 bits of its representation are used, which amounts to the number value + 2³².
Try to do it without built-in functions that convert a whole number to hex for you.value=255 → 'ff'
255 = 15 · 16 + 15, so both hex digits are f.
value=4096 → '1000'
4096 = 16³, which is a one followed by three zeros.
value=-2 → 'fffffffe'
In 32-bit two's complement, −2 is 2³² − 2 = 0xfffffffe.
value=255
'ff'
Run checks the first 3 tests in your browser. Submit checks all 55 tests on the server, hidden ones included.