<div class="cnblogs_code">
fraction = ['角','分' digit = ['零','壹','贰','叁','肆','伍','陆','柒','捌','玖' unit ='元','万','亿''','拾','佰','仟' head = n < 0 ? '欠' : ''= </span><span style="color: #0000ff">var</span> s = ''<span style="color: #000000">;
</span><span style="color: #0000ff">for</span> (<span style="color: #0000ff">var</span> i = 0; i < fraction.length; i++<span style="color: #000000">) {
s </span>+= (digit[Math.floor(n * 10 * Math.pow(10,i)) % 10] + fraction[i]).replace(/零./,''<span style="color: #000000">);
}
s </span>= s || '整'<span style="color: #000000">;
n </span>=<span style="color: #000000"> Math.floor(n);
</span><span style="color: #0000ff">for</span> (<span style="color: #0000ff">var</span> i = 0; i < unit[0].length && n > 0; i++<span style="color: #000000">) {
</span><span style="color: #0000ff">var</span> p = ''<span style="color: #000000">;
</span><span style="color: #0000ff">for</span> (<span style="color: #0000ff">var</span> j = 0; j < unit[1].length && n > 0; j++<span style="color: #000000">) {
p </span>= digit[n % 10] + unit[1][j] +<span style="color: #000000"> p;
n </span>= Math.floor(n / 10<span style="color: #000000">);
}
s </span>= p.replace(/(零.)*零$/,'').replace(/^$/,'零') + unit[0][i] +<span style="color: #000000"> s;
}
</span><span style="color: #0000ff">return</span> head + s.replace(/(零.)*零元/,'元').replace(/(零.)+/g,'零').replace(/^整$/,'零元整'<span style="color: #000000">);
}
console.log(smalltoBIG(</span>99.89)); //玖拾玖元捌角玖分</pre>