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=oct_2_hex(input)
function output=oct_2_hex(input)

% This function converts an octagonal number into corresponding hexadecimal number.
%  Class of both variables - output and input are "char".
%
% Example:
% oct_2_hex('3532432436345324764546435345433463427254364534321323123')
% ans =
% EB51A8F395A9F4B3475CB1B99C5D58F4AE345A653
if ( sign(length(input-48)-sum(sign(abs(input-48+1)+(input-48+1))))+sign(sum(abs(input-48-7)+(input-48-7))) )
    output ='Invalid Number';
else
    output=bin_2_hex(oct_2_bin(input));
end

Contact us