home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
S
/
SMC21LIB.LZH
/
ITOU.C
< prev
next >
Wrap
Text File
|
2000-06-30
|
768b
|
31 lines
#include stdio.h
/*
** itou -- convert nbr to unsigned decimal string of length sz
** right adjusted, blank filled; returns str
**
** if sz > 0 terminate with null byte
** if sz = 0 find end of string
** if sz < 0 use last byte for data
*/
itou(nbr, str, sz) int nbr; char str[]; int sz; {
int lowbit;
if(sz>0) str[--sz]=NULL;
else if(sz<0) sz = -sz;
else while(str[sz]!=NULL) ++sz;
while(sz) {
lowbit=nbr&1;
nbr=(nbr>>1)&32767; /*divide by 2*/
str[--sz]=((nbr%5<<1)+lowbit+'0');
if((nbr=nbr/5)==0) break;
}
while(sz) str[--sz]=' ';
return str;
}
029,
030,031,032,033,034,035,036,037,038,039,
040,041,042,043,044,045,046,047,
/**** 0 to 9 ****/
065,066,