
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Math Class Methods in C#
The System.Math class in C# provides methods are properties to perform mathematical operations, trigonometric, logarithmic calculations, etc.
Some of its methods include −
Sr.No | Method & Description |
---|---|
1 |
Abs(Decimal) Returns the absolute value of a Decimal number. |
2 |
Abs(Double) Returns the absolute value of a double-precision floating-point number. |
3 |
Abs(Int16) Returns the absolute value of a 16-bit signed integer. |
4 |
Abs(Int32) Returns the absolute value of a 32-bit signed integer. |
5 |
Abs(Int64) Returns the absolute value of a 64-bit signed integer. |
6 |
Abs(SByte) Returns the absolute value of an 8-bit signed integer. |
7 |
Abs(Single) Returns the absolute value of a single-precision floating-point number. |
8 |
Acos(Double) Returns the angle whose cosine is the specified number. |
9 |
Asin(Double) Returns the angle whose sine is the specified number. |
10 |
Atan(Double) Returns the angle whose tangent is the specified number. |
For all the methods, refer MSDN
Let us see an example to get the absolute value −
Example
using System; class Program { static void Main() { int val1 = 50; int val2 = -150; Console.WriteLine("Before..."); Console.WriteLine(val1); Console.WriteLine(val2); int abs1 = Math.Abs(val1); int abs2 = Math.Abs(val2); Console.WriteLine("After..."); Console.WriteLine(abs1); Console.WriteLine(abs2); } }
Advertisements