MATLAB: Does DEC2HEX or HEX2DEC work on negative numbers (twos complement)

2'scomplementconversiondatahexadecimalMATLABtwo's

I would like to use DEC2HEX and HEX2DEC on negative numbers but MATLAB only allows posiitve values.

Best Answer

The ability to use these functions on negative numbers is not available in MATLAB.
To work around this issue, use the following attached files:
ndec2hex.m
nhex2dec.m
Related Question