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

% This function converts an octagonal number into corresponding decimal number.
%  Class of both variables-output and a are "char".
%
% Example:
% oct_2_dec('3423432323563455432643242435524242445457735325263326453243245342645327') 
% ans =
% 727762791843212863701450133737761143418605884024736534705687255
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_dec(oct_2_bin(input));
end

Contact us