0 to 9 of the numbers replaced with 0 to nine uppercase characters of the function

Source: Internet
Author: User

function Changenummoneytochinese (Money) {
var cnnums = new Array ("0", "one", "II", "three", "premises", "WU", "Lu", "Qi", "ba", "JIU"); Number of Chinese characters
var cnintradice = new Array ("", "Pick", "Bai", "thousand"); Unit
var cnintunits = new Array ("", "Million", "billion", "Mega"); Corresponding integer part expansion unit
var cndecunits = new Array ("Angle", "min", "mm", "CL"); Corresponds to fractional part units
var Cninteger = "whole"; Character followed by integer amount
var cnintlast = "Yuan"; Units after completion of the integer type
var maxnum = 999999999999999.9999; Maximum number of processed
var integernum; Amount of the whole number of parts
var decimalnum; Amount of small part
var chinesestr = ""; Chinese amount string for output
var parts; 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;
return chinesestr;
}
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) > 0) {//Get integral type partial conversion
var zerocount = 0;
var intlen = integernum.length;
for (var i = 0; i < Intlen; i++) {
var n = integernum.substr (i, 1);
var p = intlen-i-1;
var q = P/4;
var m = p% 4;
if (n = = "0") {
zerocount++;
} else {
if (Zerocount > 0) {
Chinesestr + = Cnnums[0];
}
Zerocount = 0; Return to zero
Chinesestr + = Cnnums[parseint (n)] + cnintradice[m];
}
if (m = = 0 && Zerocount < 4) {
Chinesestr + = Cnintunits[q];
}
}
Chinesestr + = Cnintlast;
Integral part processing complete
}
if (decimalnum! = ") {//Decimal part
var declen = decimalnum.length;
for (var i = 0; i < Declen; i++) {
var n = 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;
}
return chinesestr;
}

0 to 9 of the numbers replaced with 0 to nine uppercase characters of the function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.