Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 3 của 3
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Hướng dẫn sử dụng Class Math trong C#

    Không rõ là trong Forum mình đã có bài viết nào về vấn đề này chưa, nhưng mình xin tự viết lấy 1 bài về nó để giới thiệu cho các bạn mới học C# có tham chiếu cho từng bài học. Mình thiết nghĩ mục đích lập trình là để tính toán trước tiên, giải quyết các vấn đề trong toán học và các hàm toán học là rất hay gặp. Vậy C# hỗ trợ vấn đề này bằng tool gì đây?
    Vấn đề được giải quyết, cơ bản là trong C# cung cấp cho ta class Math nằm trong namespace System. Các hàm toán học như: sin,cos,tan...hay số e, PI đều có ở đây.
    _Sau đây là danh sách các hàm trong class Math(Mình trích nguyên văn tiếng Anh, bạn nào muốn hiểu thêm thì dùng từ điển tra nhé, vì nhiều cái dịch ra không sát nghĩa lắm nên mình không dám dịch).
    --------
    Abs:Overloaded. Returns the absolute value of a specified number.
    Acos:Returns the angle whose cosine is the specified number.
    Asin:Returns the angle whose sine is the specified number.
    Atan:Returns the angle whose tangent is the specified number.
    Atan2:Returns the angle whose tangent is the quotient of two specified numbers.
    BigMul:Produces the full product of two 32-bit numbers.
    Ceiling:Overloaded. Returns the smallest integer greater than or equal to the specified number.
    Cos:Returns the cosine of the specified angle.
    Cosh:Returns the hyperbolic cosine of the specified angle.
    DivRem:Overloaded. Calculates the quotient of two numbers and also returns the remainder in an output parameter.
    Equals :Overloaded. Determines whether two Object instances are equal. (inherited from Object)
    Exp:Returns e raised to the specified power.
    Floor:Overloaded. Returns the largest integer less than or equal to the specified number.
    GetHashCode :Serves as a hash function for a particular type. (inherited from Object)
    GetType :Gets the Type of the current instance. (inherited from Object)
    IEEERemainder:Returns the remainder resulting from the division of a specified number by another specified number.
    Log:Overloaded. Returns the logarithm of a specified number.
    Log10:Returns the base 10 logarithm of a specified number.
    Max:Overloaded. Returns the larger of two specified numbers.
    Min:Overloaded. Returns the smaller of two numbers.
    Pow:Returns a specified number raised to the specified power.
    ReferenceEquals [IMG]images/smilies/biggrin.png[/IMG]etermines whether the specified Object instances are the same instance. (inherited from Object)
    Round:Overloaded. Rounds a value to the nearest integer or specified number of decimal places.
    Sign:Overloaded. Returns a value indicating the sign of a number.
    Sin:Returns the sine of the specified angle.
    Sinh:Returns the hyperbolic sine of the specified angle.
    Sqrt:Returns the square root of a specified number.
    Tan:Returns the tangent of the specified angle.
    Tanh:Returns the hyperbolic tangent of the specified angle.
    ToString :Returns a String that represents the current Object. (inherited from Object)
    Truncate:Overloaded. Calculates the integral part of a number.
    ---------

    _Mình đưa ra ví dụ sau để các bạn hiểu cách sử dụng nó:
    Mã nguồn PHP:
    private void Example_MathClassFunctions() { int i = 0; i = Math.Pow(5, 5); MessageBox.Show("5 to the power= " + i); i = Math.Sqrt(5); MessageBox.Show("squre root of 5= " + i); i = Math.Round(5.68743); MessageBox.Show("round figure of 5.68743= " + i); i = Math.Min(4, 7); MessageBox.Show("minimum value in 4 and 7= " + i); double j = 0; j = Math.Log(15); MessageBox.Show("Log value of 15 = " + j); j = Math.Sin(90); MessageBox.Show("sin 90 = " + j); int x = 511; int y = 50; int Value = 0; int Remainder = 0; Value = Math.DivRem(x, y, out Remainder); MessageBox.Show("value is = " + Value + " and reminder is = " + Remainder); }  
    _Như bạn đã thấy, để sử dụng các hàm trong class Math của C# thì chúng ta gọi trực tiếp thông qua tên của class, vì các phương thức trong class Math là static. Tóm lại cách gọi tổng quát là:
    Mã nguồn PHP:
    Math.*  
    Trong đó * được thay bởi các phương thức được nêu trong danh sách trên.

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Bạn xem cái này nè:

    Mã nguồn PHP:
    #region Assembly mscorlib.dll, v4.0.30319 // C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll #endregion using System.Runtime; using System.Runtime.ConstrainedExecution; using System.Security; namespace System { // Summary: // Provides constants and static methods for trigonometric, logarithmic, and // other common mathematical functions. public static class Math { // Summary: // Represents the natural logarithmic base, specified by the constant, e. public const double E = 2.71828; // // Summary: // Represents the ratio of the circumference of a circle to its diameter, specified // by the constant, π. public const double PI = 3.14159; // Summary: // Returns the absolute value of a System.Decimal number. // // Parameters: // value: // A number in the range System.Decimal.MinValue≤ value ≤System.Decimal.MaxValue. // // Returns: // A System.Decimal, x, such that 0 ≤ x ≤System.Decimal.MaxValue. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static decimal Abs(decimal value); // // Summary: // Returns the absolute value of a double-precision floating-point number. // // Parameters: // value: // A number in the range System.Double.MinValue≤value≤System.Double.MaxValue. // // Returns: // A double-precision floating-point number, x, such that 0 ≤ x ≤System.Double.MaxValue. [SecuritySafeCritical] public static double Abs(double value); // // Summary: // Returns the absolute value of a single-precision floating-point number. // // Parameters: // value: // A number in the range System.Single.MinValue≤value≤System.Single.MaxValue. // // Returns: // A single-precision floating-point number, x, such that 0 ≤ x ≤System.Single.MaxValue. [SecuritySafeCritical] public static float Abs(float value); // // Summary: // Returns the absolute value of a 32-bit signed integer. // // Parameters: // value: // A number in the range System.Int32.MinValue < value≤System.Int32.MaxValue. // // Returns: // A 32-bit signed integer, x, such that 0 ≤ x ≤System.Int32.MaxValue. // // Exceptions: // System.OverflowException: // value equals System.Int32.MinValue. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Abs(int value); // // Summary: // Returns the absolute value of a 64-bit signed integer. // // Parameters: // value: // A number in the range System.Int64.MinValue < value≤System.Int64.MaxValue. // // Returns: // A 64-bit signed integer, x, such that 0 ≤ x ≤System.Int64.MaxValue. // // Exceptions: // System.OverflowException: // value equals System.Int64.MinValue. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long Abs(long value); // // Summary: // Returns the absolute value of an 8-bit signed integer. // // Parameters: // value: // A number in the range System.SByte.MinValue < value≤System.SByte.MaxValue. // // Returns: // An 8-bit signed integer, x, such that 0 ≤ x ≤System.SByte.MaxValue. // // Exceptions: // System.OverflowException: // value equals System.SByte.MinValue. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [CLSCompliant(false)] public static sbyte Abs(sbyte value); // // Summary: // Returns the absolute value of a 16-bit signed integer. // // Parameters: // value: // A number in the range System.Int16.MinValue < value≤System.Int16.MaxValue. // // Returns: // A 16-bit signed integer, x, such that 0 ≤ x ≤System.Int16.MaxValue. // // Exceptions: // System.OverflowException: // value equals System.Int16.MinValue. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static short Abs(short value); // // Summary: // Returns the angle whose cosine is the specified number. // // Parameters: // d: // A number representing a cosine, where -1 ≤d≤ 1. // // Returns: // An angle, θ, measured in radians, such that 0 ≤θ≤π-or- System.Double.NaN // if d < -1 or d > 1. [SecuritySafeCritical] public static double Acos(double d); // // Summary: // Returns the angle whose sine is the specified number. // // Parameters: // d: // A number representing a sine, where -1 ≤d≤ 1. // // Returns: // An angle, θ, measured in radians, such that -π/2 ≤θ≤π/2 -or- System.Double.NaN // if d < -1 or d > 1. [SecuritySafeCritical] public static double Asin(double d); // // Summary: // Returns the angle whose tangent is the specified number. // // Parameters: // d: // A number representing a tangent. // // Returns: // An angle, θ, measured in radians, such that -π/2 ≤θ≤π/2.-or- System.Double.NaN // if d equals System.Double.NaN, -π/2 rounded to double precision (-1.5707963267949) // if d equals System.Double.NegativeInfinity, or π/2 rounded to double precision // (1.5707963267949) if d equals System.Double.PositiveInfinity. [SecuritySafeCritical] public static double Atan(double d); // // Summary: // Returns the angle whose tangent is the quotient of two specified numbers. // // Parameters: // y: // The y coordinate of a point. // // x: // The x coordinate of a point. // // Returns: // An angle, θ, measured in radians, such that -π≤θ≤π, and tan(θ) = y / x, where // (x, y) is a point in the Cartesian plane. Observe the following: For (x, // y) in quadrant 1, 0 < θ < π/2.For (x, y) in quadrant 2, π/2 < θ≤π.For (x, // y) in quadrant 3, -π < θ < -π/2.For (x, y) in quadrant 4, -π/2 < θ < 0.For // points on the boundaries of the quadrants, the return value is the following:If // y is 0 and x is not negative, θ = 0.If y is 0 and x is negative, θ = π.If // y is positive and x is 0, θ = π/2.If y is negative and x is 0, θ = -π/2. [SecuritySafeCritical] public static double Atan2(double y, double x); // // Summary: // Produces the full product of two 32-bit numbers. // // Parameters: // a: // The first System.Int32 to multiply. // // b: // The second System.Int32 to multiply. // // Returns: // The System.Int64 containing the product of the specified numbers. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long BigMul(int a, int b); // // Summary: // Returns the smallest integral value that is greater than or equal to the // specified decimal number. // // Parameters: // d: // A decimal number. // // Returns: // The smallest integral value that is greater than or equal to d. Note that // this method returns a System.Decimal instead of an integral type. public static decimal Ceiling(decimal d); // // Summary: // Returns the smallest integral value that is greater than or equal to the // specified double-precision floating-point number. // // Parameters: // a: // A double-precision floating-point number. // // Returns: // The smallest integral value that is greater than or equal to a. If a is equal // to System.Double.NaN, System.Double.NegativeInfinity, or System.Double.PositiveInfinity, // that value is returned. Note that this method returns a System.Double instead // of an integral type. [SecuritySafeCritical] public static double Ceiling(double a); // // Summary: // Returns the cosine of the specified angle. // // Parameters: // d: // An angle, measured in radians. // // Returns: // The cosine of d. If d is equal to System.Double.NaN, System.Double.NegativeInfinity, // or System.Double.PositiveInfinity, this method returns System.Double.NaN. [SecuritySafeCritical] public static double Cos(double d); // // Summary: // Returns the hyperbolic cosine of the specified angle. // // Parameters: // value: // An angle, measured in radians. // // Returns: // The hyperbolic cosine of value. If value is equal to System.Double.NegativeInfinity // or System.Double.PositiveInfinity, System.Double.PositiveInfinity is returned. // If value is equal to System.Double.NaN, System.Double.NaN is returned. [SecuritySafeCritical] public static double Cosh(double value); // // Summary: // Calculates the quotient of two 32-bit signed integers and also returns the // remainder in an output parameter. // // Parameters: // a: // The dividend. // // b: // The divisor. // // result: // The remainder. // // Returns: // The quotient of the specified numbers. // // Exceptions: // System.DivideByZeroException: // b is zero. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int DivRem(int a, int b, out int result); // // Summary: // Calculates the quotient of two 64-bit signed integers and also returns the // remainder in an output parameter. // // Parameters: // a: // The dividend. // // b: // The divisor. // // result: // The remainder. // // Returns: // The quotient of the specified numbers. // // Exceptions: // System.DivideByZeroException: // b is zero. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long DivRem(long a, long b, out long result); // // Summary: // Returns e raised to the specified power. // // Parameters: // d: // A number specifying a power. // // Returns: // The number e raised to the power d. If d equals System.Double.NaN or System.Double.PositiveInfinity, // that value is returned. If d equals System.Double.NegativeInfinity, 0 is // returned. [SecuritySafeCritical] public static double Exp(double d); // // Summary: // Returns the largest integer less than or equal to the specified decimal number. // // Parameters: // d: // A decimal number. // // Returns: // The largest integer less than or equal to d. public static decimal Floor(decimal d); // // Summary: // Returns the largest integer less than or equal to the specified double-precision // floating-point number. // // Parameters: // d: // A double-precision floating-point number. // // Returns: // The largest integer less than or equal to d. If d is equal to System.Double.NaN, // System.Double.NegativeInfinity, or System.Double.PositiveInfinity, that value // is returned. [SecuritySafeCritical] public static double Floor(double d); // // Summary: // Returns the remainder resulting from the division of a specified number by // another specified number. // // Parameters: // x: // A dividend. // // y: // A divisor. // // Returns: // A number equal to x - (y Q), where Q is the quotient of x / y rounded to // the nearest integer (if x / y falls halfway between two integers, the even // integer is returned).If x - (y Q) is zero, the value +0 is returned if x // is positive, or -0 if x is negative.If y = 0, System.Double.NaN is returned. [SecuritySafeCritical] public static double IEEERemainder(double x, double y); // // Summary: // Returns the natural (base e) logarithm of a specified number. // // Parameters: // d: // A number whose logarithm is to be found. // // Returns: // One of the values in the following table. d parameterReturn value Positive // The natural logarithm of d; that is, ln d, or log edZero System.Double.NegativeInfinityNegative // System.Double.NaNEqual to System.Double.NaNSystem.Double.NaNEqual to System.Double.PositiveInfinitySystem.Double.PositiveInfinity [SecuritySafeCritical] public static double Log(double d); // // Summary: // Returns the logarithm of a specified number in a specified base. // // Parameters: // a: // A number whose logarithm is to be found. // // newBase: // The base of the logarithm. // // Returns: // One of the values in the following table. (+Infinity denotes System.Double.PositiveInfinity, // -Infinity denotes System.Double.NegativeInfinity, and NaN denotes System.Double.NaN.)anewBaseReturn // valuea> 0(0 <newBase< 1) -or-(newBase> 1)lognewBase(a)a< 0(any value)NaN(any // value)newBase< 0NaNa != 1newBase = 0NaNa != 1newBase = +InfinityNaNa = NaN(any // value)NaN(any value)newBase = NaNNaN(any value)newBase = 1NaNa = 00 <newBase< // 1 +Infinitya = 0newBase> 1-Infinitya = +Infinity0 <newBase< 1-Infinitya = // +InfinitynewBase> 1+Infinitya = 1newBase = 00a = 1newBase = +Infinity0 public static double Log(double a, double newBase); // // Summary: // Returns the base 10 logarithm of a specified number. // // Parameters: // d: // A number whose logarithm is to be found. // // Returns: // One of the values in the following table. d parameter Return value Positive // The base 10 log of d; that is, log 10d. Zero System.Double.NegativeInfinityNegative // System.Double.NaNEqual to System.Double.NaNSystem.Double.NaNEqual to System.Double.PositiveInfinitySystem.Double.PositiveInfinity [SecuritySafeCritical] public static double Log10(double d); // // Summary: // Returns the larger of two 8-bit unsigned integers. // // Parameters: // val1: // The first of two 8-bit unsigned integers to compare. // // val2: // The second of two 8-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static byte Max(byte val1, byte val2); // // Summary: // Returns the larger of two decimal numbers. // // Parameters: // val1: // The first of two System.Decimal numbers to compare. // // val2: // The second of two System.Decimal numbers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static decimal Max(decimal val1, decimal val2); // // Summary: // Returns the larger of two double-precision floating-point numbers. // // Parameters: // val1: // The first of two double-precision floating-point numbers to compare. // // val2: // The second of two double-precision floating-point numbers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. If val1, val2, or both val1 // and val2 are equal to System.Double.NaN, System.Double.NaN is returned. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static double Max(double val1, double val2); // // Summary: // Returns the larger of two single-precision floating-point numbers. // // Parameters: // val1: // The first of two single-precision floating-point numbers to compare. // // val2: // The second of two single-precision floating-point numbers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. If val1, or val2, or both val1 // and val2 are equal to System.Single.NaN, System.Single.NaN is returned. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static float Max(float val1, float val2); // // Summary: // Returns the larger of two 32-bit signed integers. // // Parameters: // val1: // The first of two 32-bit signed integers to compare. // // val2: // The second of two 32-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static int Max(int val1, int val2); // // Summary: // Returns the larger of two 64-bit signed integers. // // Parameters: // val1: // The first of two 64-bit signed integers to compare. // // val2: // The second of two 64-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long Max(long val1, long val2); // // Summary: // Returns the larger of two 8-bit signed integers. // // Parameters: // val1: // The first of two 8-bit signed integers to compare. // // val2: // The second of two 8-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [CLSCompliant(false)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static sbyte Max(sbyte val1, sbyte val2); // // Summary: // Returns the larger of two 16-bit signed integers. // // Parameters: // val1: // The first of two 16-bit signed integers to compare. // // val2: // The second of two 16-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static short Max(short val1, short val2); // // Summary: // Returns the larger of two 32-bit unsigned integers. // // Parameters: // val1: // The first of two 32-bit unsigned integers to compare. // // val2: // The second of two 32-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [CLSCompliant(false)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static uint Max(uint val1, uint val2); // // Summary: // Returns the larger of two 64-bit unsigned integers. // // Parameters: // val1: // The first of two 64-bit unsigned integers to compare. // // val2: // The second of two 64-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [CLSCompliant(false)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static ulong Max(ulong val1, ulong val2); // // Summary: // Returns the larger of two 16-bit unsigned integers. // // Parameters: // val1: // The first of two 16-bit unsigned integers to compare. // // val2: // The second of two 16-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is larger. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [CLSCompliant(false)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static ushort Max(ushort val1, ushort val2); // // Summary: // Returns the smaller of two 8-bit unsigned integers. // // Parameters: // val1: // The first of two 8-bit unsigned integers to compare. // // val2: // The second of two 8-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static byte Min(byte val1, byte val2); // // Summary: // Returns the smaller of two decimal numbers. // // Parameters: // val1: // The first of two System.Decimal numbers to compare. // // val2: // The second of two System.Decimal numbers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static decimal Min(decimal val1, decimal val2); // // Summary: // Returns the smaller of two double-precision floating-point numbers. // // Parameters: // val1: // The first of two double-precision floating-point numbers to compare. // // val2: // The second of two double-precision floating-point numbers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. If val1, val2, or both val1 // and val2 are equal to System.Double.NaN, System.Double.NaN is returned. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static double Min(double val1, double val2); // // Summary: // Returns the smaller of two single-precision floating-point numbers. // // Parameters: // val1: // The first of two single-precision floating-point numbers to compare. // // val2: // The second of two single-precision floating-point numbers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. If val1, val2, or both val1 // and val2 are equal to System.Single.NaN, System.Single.NaN is returned. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static float Min(float val1, float val2); // // Summary: // Returns the smaller of two 32-bit signed integers. // // Parameters: // val1: // The first of two 32-bit signed integers to compare. // // val2: // The second of two 32-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static int Min(int val1, int val2); // // Summary: // Returns the smaller of two 64-bit signed integers. // // Parameters: // val1: // The first of two 64-bit signed integers to compare. // // val2: // The second of two 64-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long Min(long val1, long val2); // // Summary: // Returns the smaller of two 8-bit signed integers. // // Parameters: // val1: // The first of two 8-bit signed integers to compare. // // val2: // The second of two 8-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [CLSCompliant(false)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static sbyte Min(sbyte val1, sbyte val2); // // Summary: // Returns the smaller of two 16-bit signed integers. // // Parameters: // val1: // The first of two 16-bit signed integers to compare. // // val2: // The second of two 16-bit signed integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static short Min(short val1, short val2); // // Summary: // Returns the smaller of two 32-bit unsigned integers. // // Parameters: // val1: // The first of two 32-bit unsigned integers to compare. // // val2: // The second of two 32-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [CLSCompliant(false)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static uint Min(uint val1, uint val2); // // Summary: // Returns the smaller of two 64-bit unsigned integers. // // Parameters: // val1: // The first of two 64-bit unsigned integers to compare. // // val2: // The second of two 64-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [CLSCompliant(false)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static ulong Min(ulong val1, ulong val2); // // Summary: // Returns the smaller of two 16-bit unsigned integers. // // Parameters: // val1: // The first of two 16-bit unsigned integers to compare. // // val2: // The second of two 16-bit unsigned integers to compare. // // Returns: // Parameter val1 or val2, whichever is smaller. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] [CLSCompliant(false)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static ushort Min(ushort val1, ushort val2); // // Summary: // Returns a specified number raised to the specified power. // // Parameters: // x: // A double-precision floating-point number to be raised to a power. // // y: // A double-precision floating-point number that specifies a power. // // Returns: // The number x raised to the power y. [SecuritySafeCritical] } }  
    Chịu khó ngồi dịch, và viết thử là OK![IMG]images/smilies/biggrin.png[/IMG]

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Và đây nữa:

    Mã nguồn PHP:
    #region Assembly mscorlib.dll, v4.0.30319 // C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll #endregion using System.Runtime; using System.Runtime.ConstrainedExecution; using System.Security; namespace System { // Summary: // Provides constants and static methods for trigonometric, logarithmic, and // other common mathematical functions. public static class Math { //Tiep Theo public static double Pow(double x, double y); // // Summary: // Rounds a decimal value to the nearest integral value. // // Parameters: // d: // A decimal number to be rounded. // // Returns: // The integer nearest parameter d. If the fractional component of d is halfway // between two integers, one of which is even and the other odd, the even number // is returned. Note that this method returns a System.Decimal instead of an // integral type. // // Exceptions: // System.OverflowException: // The result is outside the range of a System.Decimal. public static decimal Round(decimal d); // // Summary: // Rounds a double-precision floating-point value to the nearest integral value. // // Parameters: // a: // A double-precision floating-point number to be rounded. // // Returns: // The integer nearest a. If the fractional component of a is halfway between // two integers, one of which is even and the other odd, then the even number // is returned. Note that this method returns a System.Double instead of an // integral type. [SecuritySafeCritical] public static double Round(double a); // // Summary: // Rounds a decimal value to a specified number of fractional digits. // // Parameters: // d: // A decimal number to be rounded. // // decimals: // The number of decimal places in the return value. // // Returns: // The number nearest to d that contains a number of fractional digits equal // to decimals. // // Exceptions: // System.ArgumentOutOfRangeException: // decimals is less than 0 or greater than 28. // // System.OverflowException: // The result is outside the range of a System.Decimal. public static decimal Round(decimal d, int decimals); // // Summary: // Rounds a decimal value to the nearest integer. A parameter specifies how // to round the value if it is midway between two other numbers. // // Parameters: // d: // A decimal number to be rounded. // // mode: // Specification for how to round d if it is midway between two other numbers. // // Returns: // The integer nearest d. If d is halfway between two numbers, one of which // is even and the other odd, then mode determines which of the two is returned. // // Exceptions: // System.ArgumentException: // mode is not a valid value of System.MidpointRounding. // // System.OverflowException: // The result is outside the range of a System.Decimal. [SecuritySafeCritical] public static decimal Round(decimal d, MidpointRounding mode); // // Summary: // Rounds a double-precision floating-point value to a specified number of fractional // digits. // // Parameters: // value: // A double-precision floating-point number to be rounded. // // digits: // The number of fractional digits in the return value. // // Returns: // The number nearest to value that contains a number of fractional digits equal // to digits. // // Exceptions: // System.ArgumentOutOfRangeException: // digits is less than 0 or greater than 15. public static double Round(double value, int digits); // // Summary: // Rounds a double-precision floating-point value to the nearest integer. A // parameter specifies how to round the value if it is midway between two other // numbers. // // Parameters: // value: // A double-precision floating-point number to be rounded. // // mode: // Specification for how to round value if it is midway between two other numbers. // // Returns: // The integer nearest value. If value is halfway between two integers, one // of which is even and the other odd, then mode determines which of the two // is returned. // // Exceptions: // System.ArgumentException: // mode is not a valid value of System.MidpointRounding. public static double Round(double value, MidpointRounding mode); // // Summary: // Rounds a decimal value to a specified number of fractional digits. A parameter // specifies how to round the value if it is midway between two other numbers. // // Parameters: // d: // A decimal number to be rounded. // // decimals: // The number of decimal places in the return value. // // mode: // Specification for how to round d if it is midway between two other numbers. // // Returns: // The number nearest to d that contains a number of fractional digits equal // to decimals. If the number of fractional digits in d is less than decimals, // d is returned unchanged. // // Exceptions: // System.ArgumentOutOfRangeException: // decimals is less than 0 or greater than 28. // // System.ArgumentException: // mode is not a valid value of System.MidpointRounding. // // System.OverflowException: // The result is outside the range of a System.Decimal. [SecuritySafeCritical] public static decimal Round(decimal d, int decimals, MidpointRounding mode); // // Summary: // Rounds a double-precision floating-point value to the specified number of // fractional digits. A parameter specifies how to round the value if it is // midway between two other numbers. // // Parameters: // value: // A double-precision floating-point number to be rounded. // // digits: // The number of fractional digits in the return value. // // mode: // Specification for how to round value if it is midway between two other numbers. // // Returns: // The number nearest to value that has a number of fractional digits equal // to digits. If the number of fractional digits in value is less than digits, // value is returned unchanged. // // Exceptions: // System.ArgumentOutOfRangeException: // digits is less than 0 or greater than 15. // // System.ArgumentException: // mode is not a valid value of System.MidpointRounding. public static double Round(double value, int digits, MidpointRounding mode); // // Summary: // Returns a value indicating the sign of a decimal number. // // Parameters: // value: // A signed System.Decimal number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(decimal value); // // Summary: // Returns a value indicating the sign of a double-precision floating-point // number. // // Parameters: // value: // A signed number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. // // Exceptions: // System.ArithmeticException: // value is equal to System.Double.NaN. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(double value); // // Summary: // Returns a value indicating the sign of a single-precision floating-point // number. // // Parameters: // value: // A signed number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. // // Exceptions: // System.ArithmeticException: // value is equal to System.Single.NaN. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(float value); // // Summary: // Returns a value indicating the sign of a 32-bit signed integer. // // Parameters: // value: // A signed number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(int value); // // Summary: // Returns a value indicating the sign of a 64-bit signed integer. // // Parameters: // value: // A signed number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(long value); // // Summary: // Returns a value indicating the sign of an 8-bit signed integer. // // Parameters: // value: // A signed number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. [CLSCompliant(false)] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(sbyte value); // // Summary: // Returns a value indicating the sign of a 16-bit signed integer. // // Parameters: // value: // A signed number. // // Returns: // A number that indicates the sign of value, as shown in the following table.Return // value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value // is greater than zero. [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Sign(short value); // // Summary: // Returns the sine of the specified angle. // // Parameters: // a: // An angle, measured in radians. // // Returns: // The sine of a. If a is equal to System.Double.NaN, System.Double.NegativeInfinity, // or System.Double.PositiveInfinity, this method returns System.Double.NaN. [SecuritySafeCritical] public static double Sin(double a); // // Summary: // Returns the hyperbolic sine of the specified angle. // // Parameters: // value: // An angle, measured in radians. // // Returns: // The hyperbolic sine of value. If value is equal to System.Double.NegativeInfinity, // System.Double.PositiveInfinity, or System.Double.NaN, this method returns // a System.Double equal to value. [SecuritySafeCritical] public static double Sinh(double value); // // Summary: // Returns the square root of a specified number. // // Parameters: // d: // A number. // // Returns: // One of the values in the following table. d parameter Return value Zero, // or positive The positive square root of d. Negative System.Double.NaNEquals // System.Double.NaNSystem.Double.NaNEquals System.Double.PositiveInfinitySystem.Double.PositiveInfinity [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [SecuritySafeCritical] public static double Sqrt(double d); // // Summary: // Returns the tangent of the specified angle. // // Parameters: // a: // An angle, measured in radians. // // Returns: // The tangent of a. If a is equal to System.Double.NaN, System.Double.NegativeInfinity, // or System.Double.PositiveInfinity, this method returns System.Double.NaN. [SecuritySafeCritical] public static double Tan(double a); // // Summary: // Returns the hyperbolic tangent of the specified angle. // // Parameters: // value: // An angle, measured in radians. // // Returns: // The hyperbolic tangent of value. If value is equal to System.Double.NegativeInfinity, // this method returns -1. If value is equal to System.Double.PositiveInfinity, // this method returns 1. If value is equal to System.Double.NaN, this method // returns System.Double.NaN. [SecuritySafeCritical] public static double Tanh(double value); // // Summary: // Calculates the integral part of a specified decimal number. // // Parameters: // d: // A number to truncate. // // Returns: // The integral part of d; that is, the number that remains after any fractional // digits have been discarded. public static decimal Truncate(decimal d); // // Summary: // Calculates the integral part of a specified double-precision floating-point // number. // // Parameters: // d: // A number to truncate. // // Returns: // The integral part of d; that is, the number that remains after any fractional // digits have been discarded. public static double Truncate(double d); } }  

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •