Locked lesson.
About this lesson
In this lesson, we learn about Math Methods such as Floor, Ceiling, Round, and Truncate.
Exercise files
Download this lesson’s related exercise files.
18 - Math Methods.docx61.1 KB 18 - Math Methods SOLUTION.docx
57.9 KB
Quick reference
Math Methods
C# has a number of built in Math Methods.
When to use
Use these as needed whenever you want to do certain math functions.
Instructions
double x = 5.2d;
Math.Floor(x); // find the lower level floor
Math.Ceiling(x); // find the upper level ceiling
Math.Round(x); // Rounding the number
Math.Round(x, 2); // Round to 2 decimal places
Math.Truncate(x); // chop off decimal places
Hints & tips
- Math methods are a quick and easy way to manipulate your numbers with C#.
Lesson notes are only available for subscribers.