Chinese characters corresponding to 0-9

Source: Internet
Author: User

Protected void page_load (Object sender, eventargs E)
{
Response. Write (loancapital (2596736 ));
Response. End ();
}
Public static string loancapital (decimal num)
{
String str1 = ""; // Chinese characters corresponding to 0-9
String str2 = "tens of thousands of Chinese characters, hundreds of millions of Chinese characters, and tens of thousands of Chinese characters"; // Chinese characters corresponding to digits
String str3 = ""; // value retrieved from the original num Value
String str4 = ""; // string format of a number
String str5 = ""; // the capital amount of RMB
Int I; // cyclic variable
Int J; // multiply the value of num by the string length of 100
String delimiter = ""; // Chinese reading of numbers
String CH2 = ""; // Chinese character reading of digits
Int nzero = 0; // number of consecutive zero values used for calculation
Int temp; // value retrieved from the original num Value
Bool fushu = (Num <0 );
Num = math. Round (math. Abs (Num), 2); // returns the absolute value of num and rounding it to 2 decimal places.
Str4 = (long) (Num * 100). tostring (); // multiply num by 100 and convert it into a string
J = str4.length; // locate the highest bit
If (j> 15) {return "overflow ";}
Str2 = str2.substring (15-j); // retrieve the str2 value of the corresponding number of digits. For example: 200.55, J is 5, so str2 = hour

// Cyclically retrieve the value to be converted for each bit
For (I = 0; I <j; I ++)
{
Str3 = str4.substring (I, 1); // retrieves the value of a certain bit to be converted.
Temp = convert. toint32 (str3); // convert to a number
If (I! = (J-3) & I! = (J-7) & I! = (J-11) & I! = (J-15 ))
{
// When the number of retrieved digits is not RMB, or trillions of digits
If (str3 = "0 ")
{
Operator = "";
CH2 = "";
Nzero = nzero + 1;
}
Else
{
If (str3! = "0" & nzero! = 0)
{
Bytes = "zero" + str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
Else
{
Dependencies = str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
}
}
Else
{
// This digit is a key digit of trillions, hundreds of millions, tens of thousands, and Yuan.
If (str3! = "0" & nzero! = 0)
{
Bytes = "zero" + str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
Else
{
If (str3! = "0" & nzero = 0)
{
Dependencies = str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
Else
{
If (str3 = "0" & nzero> = 3)
{
Operator = "";
CH2 = "";
Nzero = nzero + 1;
}
Else
{
If (j> 11)
{
Operator = "";
Nzero = nzero + 1;
}
Else
{
Operator = "";
CH2 = str2.substring (I, 1 );
Nzero = nzero + 1;
}
}
}
}
}
If (I = (J-11) | I = (J-3 ))
{
// If this digit is a hundred million or a metadigit, it must be written
CH2 = str2.substring (I, 1 );
}
Str5 = str5 + separator + CH2;

If (I = J-1 & str3 = "0 ")
{
// When the last digit (minute) is 0, add an integer"
Str5 = str5 + 'Integral ';
}
}
If (num = 0)
{
Str5 = "Zero RMB ";
}
If (fushu)
Str5 = string. Format ("negative {0}", str5 );
Return str5;
}

Related Article

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.