ASP를 배워라.Net System.Math 클래스

3750 단어
구성원:
/*    */
Math.E;             //2.71828182845905
Math.PI;            //3.14159265358979

/*      */
Math.Abs;           //   
Math.Acos;          //   
Math.Asin;          //   
Math.Atan;          //   
Math.Atan2;         //   ,    
Math.BigMul;        //int32 * int32 = int64
Math.Ceiling;       //  >=      
Math.Cos;           //  
Math.Cosh;          //    
Math.DivRem;        //     
Math.Exp;           //  e      
Math.Floor;         //  <=      
Math.IEEERemainder; //  
Math.Log;           //    
Math.Log10;         //  10      
Math.Max;           //  
Math.Min;           //  
Math.Pow;           //  
Math.Round;         //    ,      
Math.Sign;          //   ,     -1、0、1 
Math.Sin;           //  
Math.Sinh;          //    
Math.Sqrt;          //   
Math.Tan;           //  
Math.Tanh;          //    
Math.Truncate;      //  

연습:
//Truncate()、Floor()、Ceiling()
protected void Button1_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, "
", n2, "
", n3, "
", n4, "
", n5); } // ( ) 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, "
", n2, "
", n3, "
", n4, "
", n5, "
", n6, "
", n7, "
", n8); } // 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, "
", n2, "
", n3, "
", n4, "
", n5, "
", n6, "
", n7, "
", n8); } // (0..28) 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, "
", n2, "
", n3, "
", n4, "
", n5, "
", n6); }

좋은 웹페이지 즐겨찾기