Learning to use ASP. NET's system. Math class

Source: Internet
Author: User
Member:
 
/* Field */math. e; // 2.71828182845905math.pi; // 3.14159265358979/* Static Method */math. ABS; // absolute value math. ACOs; // arccosine math. asin; // arcsin math. atan; // returns math. atan2; // arc tangent, two parameters math. bigmul; // int32 * int32 = int64math. ceiling; // take the smallest integer math> =. cos; // cosine math. cosh; // hyperbolic cosine math. divrem; // The operator and remainder math. exp; // evaluate the specified power math of E. floor; // fetch
Exercise:
// Truncate (), floor (), ceiling () protected void button#click (Object sender, eventargs e) {double n1 = math. truncate (math. pi); // 3 double n2 = math. floor (2.5); // 2 double N3 = math. floor (-2.5); //-3 double N4 = math. ceiling (2.5); // 3 double N5 = math. ceiling (-2.5); //-2 textbox1.text = string. concat (N1, "\ n", N2, "\ n", N3, "\ n", N4, "\ n", N5 );} // nearby round (even) protected void button2_click (Object sender, eventargs e) {double n1 = math. round (0.5); // 0 double n2 = math. round (1.5); // 2 double N3 = math. round (2.5); // 2 double N4 = math. round (3.5); // 4 double N5 = math. round (-0.5); // 0 double N6 = math. round (-1.5); //-2 double N7 = math. round (-2.5); //-2 double n8 = math. round (-3.5); //-4 textbox1.text = string. concat (N1, "\ n", N2, "\ n", N3, "\ n", N4, "\ n", N5, "\ n", N6, "\ n", N7, "\ n", n8);} // rounding protected void button3_click (Object sender, eventargs e) {double n1 = math. round (0.5, midpointrounding. awayfromzero); // 1 double n2 = math. round (1.5, midpointrounding. awayfromzero); // 2 double N3 = math. round (2.5, midpointrounding. awayfromzero); // 3 double N4 = math. round (3.5, midpointrounding. awayfromzero); // 4 double N5 = math. round (-0.5, midpointrounding. awayfromzero); //-1 double N6 = math. round (-1.5, midpointrounding. awayfromzero); //-2 double N7 = math. round (-2.5, midpointrounding. awayfromzero); //-3 double n8 = math. round (-3.5, midpointrounding. awayfromzero); //-4 textbox1.text = string. concat (N1, "\ n", N2, "\ n", N3, "\ n", N4, "\ n", N5, "\ n", N6, "\ n", N7, "\ n", n8);} // specify the number of decimal places (0 .. 28) Rounding protected void button4_click (Object sender, eventargs e) {double n1 = math. round (3.126, 2); // 3.13 double n2 = math. round (3.124, 2); // 3.12 double N3 = math. round (3.125, 2); // 3.12 double N4 = math. round (3.135, 2); // 3.14 double N5 = math. round (3.125, 2, midpointrounding. awayfromzero); // 3.13 double N6 = math. round (3.135, 2, midpointrounding. awayfromzero); // 3.14 textbox1.text = string. concat (N1, "\ n", N2, "\ n", N3, "\ n", N4, "\ n", N5, "\ n ", n6 );}
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.