Math Klass in CSharp
In this article we will discuss the Math class in CSharp. Now that you already know how classes work, it’s time to use some predefined classes. The Math class for example.
Here the different functions and what they do:
Math.Ceiling (23.3); ceil rounds to the nearest whole number, that is, to 24.
Math.Floor (7.9) ;: floor rounds to the nearest whole number, thus to 7
Math.Abs (-12.3) ;: abs calculates the absolute value (the difference to 0. always outputs a positive number)
Math.Min (2.5, 4.4) ;: min returns the lower of the two numbers.
Math.Max (2.5, 4.4) ;: max returns the higher of the two numbers.
Math.Pow (3, 4) ;: power (for exponent, for example) outputs 3 ^ 4 (three exp four). Thus 243.
Math.Sqrt (25); squareroot is the square root.
The Math class includes other important methods. sin (), sinh (), cos (), cosh (). Etc. For a complete list of the functions I recommend the documentation.