from
JDEC2HEX
by Michael Kleder
Uses Java to convert arbitrary length decimal to hex (for nonnegative integers)
|
| h=jdec2hex(d) |
function h=jdec2hex(d)
% Arbitrary length decimal to hex conversion for nonnegative integers
% Input and output are CHARACTER ARRAYS
% Output will have an even number of characters (a whole number of bytes)
% (Michael Kleder, Nov 2005)
b=java.math.BigInteger(d);
h=typecast(b.toByteArray,'uint8');
while h(1)==0 & length(h) > 1 % remove any leading zero bytes
h(1)=[];
end
h=dec2hex(h)';
if(size(h,1))==1 % if all bytes < 128, pad:
h=[repmat('0',[1 size(h,2)]);h];
end
h=lower(h(:)');
|
|
Contact us at files@mathworks.com