functionChangenummoneytochinese (Money) {varCnnums =NewArray ("0", "one", "II", "three", "Restaurant", "WU", "Lu", "Qi", "ba", "JIU");//number of Chinese characters varCnintradice =NewArray ("", "Pick", "Bai", "thousand");//basic Unit varCnintunits =NewArray ("", "Million", "billion", "Mega");//corresponding integer part expansion unit varCndecunits =NewArray ("angle", "minute", "MM", "CL");//corresponds to fractional part units varCninteger = "whole";//character followed by integer amount varCnintlast = "Yuan";//units After completion of the integer type varMaxnum = 999999999999999.9999;//maximum number of processed varIntegernum;//Amount Integer Part varDecimalnum;//amount of small part varChinesestr = "";//Chinese amount string for output varParts//array used after separating amount, pre-defined if(Money = = "")) { return""; } Money=parsefloat (Money); if(Money >=maxnum) {Alert (' exceeds maximum processing number '); return""; } if(Money = = 0) {Chinesestr= Cnnums[0] + cnintlast +Cninteger; returnChinesestr; } Money= Money.tostring ();//Convert to String if(Money.indexof (".") = =-1) {Integernum=Money ; Decimalnum= ' '; } Else{Parts= Money.split ("."); Integernum= Parts[0]; Decimalnum= Parts[1].substr (0, 4); } if(parseint (Integernum, ten) > 0) {//get integral partial conversions varZerocount = 0; varIntlen =integernum.length; for(vari = 0; i < Intlen; i++) { varn = integernum.substr (i, 1); varp = intlen-i-1; varQ = P/4; varm = p% 4; if(n = = "0") {Zerocount++; } Else { if(Zerocount > 0) {Chinesestr+ = Cnnums[0]; } Zerocount= 0;//return to zeroChinesestr + = Cnnums[parseint (n)] +Cnintradice[m]; } if(M = = 0 && Zerocount < 4) {Chinesestr+=Cnintunits[q]; }} chinesestr+=Cnintlast; //integral part processing complete } if(Decimalnum! = ") {//number of decimal parts varDeclen =decimalnum.length; for(vari = 0; i < Declen; i++) { varn = decimalnum.substr (i, 1); if(n! = ' 0 ') {Chinesestr+ = Cnnums[number (n)] +Cndecunits[i]; } } } if(Chinesestr = = "") {Chinesestr+ = Cnnums[0] + cnintlast +Cninteger; } Else if(Decimalnum = = "") {Chinesestr+=Cninteger; } returnchinesestr;}
JS converts a number into an uppercase renminbi expression