C code for converting decimal number into N base number

Status
Not open for further replies.

jaywee03

Newbie level 4
Joined
Jul 13, 2004
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
54
functions in c

d oes anyone have a code or can you recomend a site were i can find a code that converts a decimal number into its equivalent N base no.(using functions). thanx!!!!
 

Re: functions in c

Cant realy give a link for this paticular function.
but have you tried **broken link removed** have loads of stuff.
 

Re: functions in c

Hi,
You have to write your own function. It is quite easy.

start with

int conv(int base, long num)
{
rem = num%base.
num = num-rem.
rem gives the last byte
num is divisible base.


}
 

Re: functions in c

int convert(int base,long num)
{
while
{
B=num%base;
num=num/base;
c[n]=B;
n=n-1;
}
}

n is data length based on some base.
B is middle variable.
num is data.

note: output c is reverse order.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…