成员:
/* 字段 */ 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, "\n", n2, "\n", n3, "\n", n4, "\n", 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, "\n", n2, "\n", n3, "\n", n4, "\n", n5, "\n", n6, "\n", n7, "\n", 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, "\n", n2, "\n", n3, "\n", n4, "\n", n5, "\n", n6, "\n", n7, "\n", 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, "\n", n2, "\n", n3, "\n", n4, "\n", n5, "\n", n6); }
最近做项目发现未能加载文件或程序集的错误,这是由于我的机器上没有安装Ajax的原因。问题解决后,整理如下:表现:1、"System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,Pub…
1、SQL语句分类1.1、分类方法及类型1.2、数据定义语言1.3、数据操纵语言1.4、其它语句2、动态SQL理论2.1、动态SQL的用途2.2、动态SQL的语法2.3、绑定变量3、动态SQL实战3.1、封装执行DML的通用存储过程3.2、…
提供了针对可扩展的提供程序模型的基实现。命名空间:System.Configuration.Provider程序集:System.Configuration(在System.Configuration.dll中)C#publicabstra…
Web应用程序通常访问用于存储和检索动态数据的数据源。可以通过编写代码来使用System.Data命名空间(通常称为ADO.NET)和System.Xml命名空间中的类访问数据。此方法在ASP.NET的以前版本中很常见。但是,ASP.NET…
直接在类中使用Server.MapPath会出现错误,这是由于类中不能直接使用System.Web.UI.Page的非静态函数造成的。解决方法有两种:方法一、为类增加继承classCFoo:System.Web.UI.Page方法二、利用上…
XMLWeb服务在类实现派生于WebService类的XMLWeb服务时,可以使用和其他ASP.NET应用程序相同的状态管理选项。WebService类包含许多公共ASP.NET对象,包括Session和Application对象。Appl…
<%@PageLanguage="C#"Inherits="System.Web.Mvc.ViewPage"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN…
<%@PageLanguage="C#"Inherits="System.Web.Mvc.ViewPage<IEnumerable<SQSMvcSolution.Models.Model.TicketPlans>&g…