我有一个C语言版的,pascal版的不记得丢哪去了,写是写过的,要楼上写的不好用,再说
另,注意386应该转换成叁佰捌拾陆圆整.
AnsiString __fastcall FloatToCurr(double fSum)
{
String sSum="";
bool LastIsZero=false;
bool TheEndIsZero=false;
bool Wang=false;
unsigned __int64 iSumi,iSumr;
String S[]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
String R[]={"分","角","圆","拾","佰","仟","万","拾","佰","仟","亿"};
iSumi= __int64((fSum+0.005)*100);
for(int i=0;i<10,iSumi>0;i++)
{
iSumr=iSumi%10;
iSumi/=10;
if(iSumr!=0)
{
LastIsZero=false;
int iIndex = iSumr;
sSum=AnsiString(S[iIndex])+AnsiString(R)+sSum;
if(i==6)Wang=true;
}
else
{
if(i==0)
{
TheEndIsZero=true;
LastIsZero=true;
}
else
{
if(i==2)sSum="圆"+sSum;
else
{
// if(i==3&&iSumi%10!=0) sSum="拾"+sSum;
// if(i==4&&iSumi%10!=0) sSum="佰"+sSum;
// if(i==5&&iSumi%10!=0) sSum="仟"+sSum;
// else
// {
if(!LastIsZero)
{
sSum="零"+sSum;
}
if(i>=6&&!Wang)
{
sSum="万"+sSum;
Wang=true;
}
}
}
LastIsZero=true;
}
}
if(TheEndIsZero)sSum+="整";
return sSum;
}