Convert lowercase digital amount to uppercase

xiaoxiao2021-03-06  90

function convertCurrency (currencyDigits) {// Constants: var MAXIMUM_NUMBER = 99999999999.99; // Predefine the radix characters and currency symbols for output: var CN_ZERO = "zero"; var CN_ONE = "One"; var CN_TWO = "II"; var CN_THREE = ""; Var cn_four = ""; var cn_five = "Wu"; var cn_six = "Lu"; var cn_seven = "柒"; var cn_eight = "捌"; var cn_nine = "玖"; var cn_ten = "Pick up"; VAR CN_HUNDRED = ""; var cn_thousand = "仟"; var cn_ten_thousand = "10,000"; var cn_hundred_million = "100 million"; var cn_symbol = "RMB"; var cn_dollar = "yuan"; var cn_ten_cent = " "VAR CN_CENT =" division "; var cn_integer =" whole "; // variables: var integral; // represent Integral Part of Digit Number. Var decimal; // represent decimal part of digit number. Var outputcharacters; ///// . The output result var parts; var digits, radices, bigRadices, decimals; var zeroCount; var i, p, d; var quotient, modulus; // Validate input string: currencyDigits = currencyDigits.toString (); if (currencyDigits == "") {Alert ("EMPTY INPUT!"); Return ";} Ncydigits.match (/[1) {Alert ("INVALID Characters in The Input String!"); Return ";} if ((currencydigits) .match (/ ^ (/ D {1,3} (, / d {3}) * ((/ D {3},) * / d {1, 3})))))))))))))?) | (/ d (./ D )?))) $ /) == NULL) {Alert ("Illegal format of digit number!"); return "";} // normalize the format of infut digits: currencydigits = currencydigits.Replace (/ g, ""); / / Remove Comma Delimiters. Currencydigits =

currencyDigits.replace (/ ^ 0 /, "");.. // Trim zeros at the beginning // Assert the number is not greater than the maximum number if (Number (currencyDigits)> MAXIMUM_NUMBER) {alert ( "Too large a number to convert "); return" ";} // Process the coversion from currency digits to characters:! // Separate integral and decimal parts before processing coversion:". "parts = currencyDigits.split (); if (parts. Length> 1) {Integral = Parts [0]; DECIMAL = Parts [1]; // Cut Down Redundant Decimal Digits That Are Instimal.Substr (0, 2);} else {integral = parts [ 0]; decimal = "";} // Prepare the characters corresponding to the digits: digits = new Array (CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE); radices = new Array ( "", CN_TEN, CN_HUNDRED, CN_THOUSAND); bigRadices = new Array ( "", CN_TEN_THOUSAND, CN_HUNDRED_MILLION); decimals = new Array (CN_TEN_CENT, CN_CENT); // Start processing: outputCharacters = ""; // Process integ RAL Part IT IT IS LARGER THAN 0: IF (Integral> 0) {zerocount = 0; for (i = 0; I 0) {OutputCharacters = Digits [0] } Zerocount = 0; OUTPUTCHARACTERS = DIGITS [Number (D)] Radices [MODULUS];} if (MODULUS == 0 && Zerocount <4) {OutputCharacters = BIGRADICES [quotient];

}}}} OutputCharacters = cn_dollar;} // process decimal part if there is: if (decimal! = "") {For (i = 0; i

Function Atoc (NumberValue) {var NumberValue = New String (Math.Round (NumberValue * 100)); // Digital amount var chinesevalue = ""; // Translated Chinese characters VAR STRING1 = "Zero Zibo Lu Lu Lu柒捌 玖 "; // Chinese characters digital var string2 =" Wan Yiyi pick up hundreds of millions of 佰 佰 万 万 佰 佰 元 "; // Corresponding unit var len = NumberValue.Length; // Numbervalue string length var chain ; // Digital Chinese Reading VAR CH2; // Digital Bit Chinese Character Ready VAR NZERO = 0; // Used to calculate the number of variable value of the continuous zero value VAR string3; // Specify the value IF (Len> 15 ) {ALERT ("exceeds the calculation range"); return "";} if (numbervalue == 0) {ChineseValue = "zero"; return chinesevalue;} string2 = string2.substr (string2.length-len, len) ; // Remove the value for string2 of the corresponding position, for (VAR I = 0; I

String1.substr (String3, 1); CH2 = String2.substr (i, 1); NZERO = 0;} else if (string3 == 0 && Nzero> = 3) {CH1 = "; CH2 =" "; Nzero = NZERO 1;} else {ch1 = ""; ch2 = string2.substr (i, 1); nzero = NZERO 1;} if (i == (LEN - 11) || i == (LEN - 3 ))) {// If the bit is a billion or a bit bit, you must write CH2 = String2.Substr (i, 1);}} ChineseValue = ChineseValue CH1 CH2;} if (string3 == 0) {/ / Last (minute) is 0, plus "whole" ChineseValue = ChineseValue "whole";}} =======} ================================================================================================================================================= ==============================================================================================================================================

Function Chinese (NUM) {if (! / ^ / d * (/./ D *)? $ /. TEST (NUM)) {Alert ("Number IS WRONG!"); Return False;

Var aa = new array ("zero", "", "", "", "", "Wu", "柒", "捌", "玖"); var bb = New Array, "Pick", "", "仟", "10 million", "" "); var cc = new array (" angle "," points ","% "); Var A = (" Num) .Replace (/ (^ 0 *) / g, "") .split ("."), K = 0, re = ";

For (var i = a [0] .length-1; i> = 0; I - {switch (k) {case 0: re = bb [7] re; break; case 4: if (! new RegeXp ("0 {4} // D {" (a [0] .length-i-1) "} $"). TEST (A [0])) RE = BB [4] Re; Break Case 8: Re = BB [5] Re; Bb [7] = BB [5]; K = 0; Break;} IF (k% 4 == 2 && a [0] .Charat (i 2) ! = 0 && a [0] .Charat (i 1) == 0) RE = aa [0] Re; if (a [0] .Charat (i)! = 0) RE = aa [a [0) ] .Charat (i)] bb [k% 4] re; k ;} if (a.length> 1) // plus fractional part (if there is a fraction) {RE = BB [6]; for (VAR i = 0; i 2) Break; Re = aa [a [1] .Charat (i)] cc [i];}} return RE;}

==== Another implementation ========================================== =========================== function tochinese (NUM) {var arr1 = new array ("Yuan", "10,000", "100 million" Num = Num.Tostring (); var strretn = ""; if (Num.Charat (0) == "-") {Strrtn = "( negative )"; Num = Num. Substring (1, Num.Length);} var ss = Num.Split ("."); var integer = ss [0]; var float = ss [1]; if (float.length> 2) {float = float .substring (0, 2);} if (Integer.Length> 12) {Alert ("The value exceeds 100 billion, not recognized!"); returnity more than 100 billion, unrecognizable! "

Var part = splitfour (Integer); var plen = part.length; for (var i = 0; i 1) STRTN = ReadFour (part [i], 0 Arr1 [Plen-1-I]; Else Strrtn = ReadFour (Part [i], 1) Arr1 [Plen-1-i];} if (! float ||! checkzero (float) {strretn = " "Else {strretn = afterpoint (float);} return strretn;

Function afterpoint (num) {var arr1 = new array ("angle", "points"); var arr2 = new array ("zero", "", "", "", "", "Wu" , "Lu", "柒", "捌", ""); var str = ""; for (var i = 0; i


New Post(0)