Number.prototype.zhStr = function() {
02 var zh1 = ['零','壹','貳','叁','肆','伍','陆','柒','捌','玖'],
03 zh2 = ['','','拾','佰','千','万','十万','百万','千万'],
04 zh3 = ['元','角','分'];
05 var str,
06 rslt = '';
07 if(this<0) {
08 rslt = "负";
09 str = '' + -this;
10 } else {
11 str = '' + this;
12 }
13 if(str.indexOf(".")==-1) { //整数
14 if(str.length>8) return '超出计算范围!';
15 for(i=0;i<str.length;i++) {
16 rslt += zh1[str[i]] + zh2[str.length-i];
17 }
18 rslt += zh3[0] + zh1[0] + zh3[1] + zh1[0] + zh3[2];
19 } else { // 小数
20 var intnum = str.split(".")[0]; // str='123'
21 var decnum = str.split(".")[1];
22 for(i=0;i<intnum.length;i++) {
23 rslt += zh1[intnum[0]] + zh2[intnum.length-i];
24 }
25 rslt += zh3[0] + zh1[decnum[0]] + zh3[1] + zh1[decnum[2]<5?decnum[1]:decnum[1]+1] + zh3[2];
26 }
27 return rslt;
28 }