from
NUMBER SYSTEMS/ BASE CONVERTER
by Divakar Roy
Convert a number between different number systems-hex,oct,bin,dec.
|
| output=dec_2_oct(input)
|
function output=dec_2_oct(input)
% This function converts an decimal number into corresponding octagonal number.
% Class of both variables - output and input are "char".
%
% Example:
% dec_2_oct('3423432323563455432643242435524242445457735325263326453243245342645327')
% ans =
% 77373335764716516477107330113172733565105561077056067173304146511645015456117
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_oct(dec_2_bin(input));
end
|
|
Contact us at files@mathworks.com