The original implementation of the toString method was designed to only handle numerical base representations. When a string-based representation like 'hex' was passed to the method, it was not recognized or processed, and the method defaulted to returning the decimal string representation of the number (base = 10)
Summary:
Enhanced the toString method to correctly handle string-based base representations, ensuring that .toString('hex') and .toString(16) return the expected hexadecimal format of the number.
Added a test case to validate the correct conversion of numbers to hexadecimal.
Fixes #60
Root Cause
The original implementation of the toString method was designed to only handle numerical base representations. When a string-based representation like
'hex'
was passed to the method, it was not recognized or processed, and the method defaulted to returning the decimal string representation of the number (base = 10
)Summary:
.toString('hex')
and.toString(16)
return the expected hexadecimal format of the number.