Code covered by the BSD License  

Highlights from
NUMBER SYSTEMS/ BASE CONVERTER

image thumbnail

NUMBER SYSTEMS/ BASE CONVERTER

by

 

13 Aug 2006 (Updated )

Convert a number between different number systems-hex,oct,bin,dec.

output=dec_2_hex(input)
function output=dec_2_hex(input)

% This function converts an decimal number into corresponding hexagonal number.
%  Class of both variables - output and input are "char".
%
% Example:
% dec_2_hex('3423432323563455432643242435524242445457735325263326453243245342645327') 
% ans =
% 7EFB6EFD39D4E9F91DB04B3D76EEA45B88FC5C373DB10CD49D28365C4F
if ( sign(length(input-48)-sum(sign(abs(input-48+1)+(input-48+1))))+sign(sum(abs(input-48-9)+(input-48-9))) )
    output ='Invalid Number';
else
    output=bin_2_hex(dec_2_bin(input));
end

Contact us