• Math 类的方法概要


    用sivlerlight做动画和特效时经常会用到Math类,总结一下。
    参考:http://www.cnblogs.com/del/archive/2011/01/03/1924746.html

    //返回数字的绝对值
    Console.WriteLine(Math.Abs(-10));
    //向上进位取整
    Console.WriteLine(Math.Ceiling(32.1));//33
    Console.WriteLine(Math.Ceiling(32.0));//32
    Console.WriteLine(Math.Ceiling(-32.1));//32
    Console.WriteLine(Math.Ceiling((decimal)(7 + 9) / 10));
    //向下舍位取整
    Console.WriteLine(Math.Floor(32.9));//32
    Console.WriteLine(Math.Floor(32.0));//32
    
    Console.WriteLine(Math.Floor(-32.5));       //-33
    
    Console.WriteLine(Math.Max(1, 9));//9
    Console.WriteLine(Math.Min(1, 9));//1
    Console.WriteLine(Math.Pow(2, 3));//8
    //取指定位数的小数 四舍六入五考虑,五后非零就进一,五后皆零看奇偶,五前为偶应舍 去,五前为奇要进一
    
    Math.Round(0.5);  // 0
    Math.Round(1.5);  // 2
    Math.Round(2.5);  // 2
    Math.Round(3.5);  // 4
    Math.Round(-0.5); // 0
    Math.Round(-1.5); //-2
    Math.Round(-2.5); //-2
    Math.Round(-3.5); //-4
    
    Math.Round(0.5, MidpointRounding.AwayFromZero);  // 1
    Math.Round(1.5, MidpointRounding.AwayFromZero);  // 2 
    Math.Round(2.5, MidpointRounding.AwayFromZero);  // 3
    Math.Round(3.5, MidpointRounding.AwayFromZero);  // 4 
    Math.Round(-0.5, MidpointRounding.AwayFromZero); //-1
    Math.Round(-1.5, MidpointRounding.AwayFromZero); //-2
    Math.Round(-2.5, MidpointRounding.AwayFromZero); //-3
    Math.Round(-3.5, MidpointRounding.AwayFromZero); //-4
    
    
    Console.WriteLine(Math.Round(3.4452, 2));//3.45 
    Console.WriteLine(Math.Round(3.4552, 2));//3.46;
    Console.WriteLine(Math.Round(3.4652, 2));//3.47;
    
    Console.WriteLine(System.Double.NaN);//非数字
    Console.WriteLine(System.Double.NegativeInfinity);//负无穷大
    Console.WriteLine(System.Double.PositiveInfinity);//正无穷大
    
  • 相关阅读:
    细说javascripe事件传播流程
    由浅入深的讲述Get和Post的区别
    使用windowsAPI 加载shellcode
    从PE资源加载和执行Shellcode
    DLL注入
    shellcode注入原理
    asp.net学习--ashx一句话木马
    asp.net学习--asmx一句话木马
    asp.net学习--svc一句话木马
    php--莫客服系统代码审计(已申请CNVD)
  • 原文地址:https://www.cnblogs.com/geass/p/2005826.html
Copyright © 2020-2023  润新知