System.Math എന്ന ക്ലാസ് ഒരു ഗണിത സഹായിയാണ്. ത്രികോണമിതിയും (Trigonometry), ലോഗരിഥവും (Logarithm) മറ്റ് സാധാരണയായി ഉപയോഗിയ്ക്കുന്ന ഗണിത ആവശ്യങ്ങളും ഈ ക്ലാസ്സിന്റെ സഹായത്താല് എളുപ്പത്തില് ചെയ്യാന് സാധിക്കും. നാം കൂടുതലായി ഉപയോഗിക്കുവാന് സാധ്യതയുള്ള ഫംഗ്ഷനുകള് (Functions) ചുവടെ കൊടുത്തിരിക്കുന്നു.
| Function() | Return value |
|---|---|
| Abs | Absolute value |
| Ceiling | Smallest integral value that is greater than or equal to the specified number |
| Sin | Sine of the specified angle |
| Cos | Cosine of the specified angle |
| Tan | Tangent of the specified angle |
| Floor | Largest integer less than or equal to the specified number |
| Log | Natural (base e) logarithm of a specified number |
| Max | Largest of two numbers |
| Min | Smallest of two numbers |
| Pow | Raised to the specified power (x^y) |
| Round | Rounds the number |
| Truncate | Integral part of the specified number |
പൂര്ണമായ പട്ടിക ഇവിടെ വായിയ്ക്കാം.
Math എന്ന ക്ലാസ് System നെയിംസ്പെയിസില് തന്നെ ഉള്ളതാണ് അതിനാല് ഇത് പ്രത്യേകം (using) ഉള്പ്പെടുത്തേണ്ടതില്ല. ഇവയുടെ ഉപയോഗരീതി ചില ഉദാഹരണങ്ങളിലൂടെ നമുക്ക് നോക്കാം
പ്രോഗ്രാം
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double d = 56.6434;
Console.WriteLine("Original Number : " + d.ToString());
double r = Math.Round(d);
Console.WriteLine("Rounded (Math.Round) : " + r.ToString());
Console.WriteLine("Square root (Math.Sqrt) : " + Math.Sqrt(d));
Console.WriteLine("Largest (Math.Max) : " + Math.Max(62, d));
Console.WriteLine("Smallest (Math.Min) : " + Math.Min(62, d));
Console.WriteLine("Sine (Math.Sin) : " + Math.Sin(d));
Console.WriteLine("Logarithm (Math.Log) : " + Math.Log(d));
Console.WriteLine("Logarithm (Math.Log) : " + Math.Log(d));
Console.WriteLine("Truncate (Math.Truncate) : " + Math.Truncate(d));
Console.WriteLine("Power of (Math.Pow) : " + Math.Pow(d, 2));
Console.WriteLine("Floor (Math.Floor) : " + Math.Floor(d));
Console.WriteLine("Ceiling (Math.Ceiling) : " + Math.Ceiling(d));
Console.ReadKey();
}
}
}
പ്രോഗ്രാമിന്റെ output ഇങ്ങനെയാണെന്ന് കാണാം. 12-ആം നമ്പര് വരി ഒരു വേരിയബിള് ഉപയോഗിച്ചും മറ്റുള്ളവ നേരിട്ടു ഫംഗ്ഷന് വിളിച്ചും (Call) ആണെന്ന് നിങ്ങളുടെ ശ്രദ്ധയില് പെട്ടിട്ടുണ്ടാകുമല്ലോ. അങ്ങനെ വ്യത്യസ്ഥ രീതികളില് നിങ്ങള്ക്ക് ഫംഗ്ഷനുകള് ഉപയോഗിക്കാം. ഇത് Math ക്ലാസ്സിന് മാത്രമല്ല ഡോട്നെറ്റിലെ ഏത് ഫംഗ്ഷനും ബാധകമാണ്.
- C# അടിസ്ഥാന പാഠങ്ങൾ – Mathematical Operators – Math - December 10, 2014
- System namespace ( .net Study Guide) - December 10, 2014
- C# അടിസ്ഥാന പാഠങ്ങൾ – Mathematical Operators - November 22, 2014
- ഒരു DOTNET പ്രോഗ്രാം പ്രവർത്തിക്കുന്നത് എങ്ങിനെ? - November 22, 2014
- ആരാണ് ഒരു Systems Analyst? - November 9, 2014
- ഒരു DOTNET പ്രോഗ്രാമ്മിന്റെ ഘടന - November 8, 2014
- Visual Studio – ഒരു Hello World ആമുഖം - November 1, 2014
- Hello World DOTNET - October 25, 2014
- ഐടി തുടക്കക്കാർക്ക് MTA Certification - October 24, 2014
- ഡോട്ട് നെറ്റ് പഠന പരമ്പര -ആമുഖം - October 22, 2014