|
|
本帖最后由 白日蜜语 于 2022-9-6 17:29 编辑
//阿拉伯数字转中文数字
var changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
var unit = ["", "十", "百", "千", "万"];
/*数字返回汉字,最大 千亿 */
function returnCN(num) {
num = Math.floor(num)
var ny = Math.floor(num / 100000000);
num = ny ? (num - ny * 100000000) : num;
var nw = Math.floor(num / 10000);
num = nw ? (num - nw * 10000) : num;
var znum = ny ? getCh(ny) + '亿' + getCh(nw) + '万' + getCh(num) : nw ? getCh(nw) + '万' + getCh(num) : getCh(num);
if (num < 20) {
znum = znum.replace('一十', '十');
}
return znum
};
可参考一下 |
|