Learn to Code via Tutorials on Repl.it!

← Back to all posts

# Math method time

There are bunch of math methods for c# and here they are

Now for some math methods you can se what you have as the new variable ex mathTime = math function(mathTime) or set an empty variable to use emptyvariable = math function(mathTime)

``````double emptyItem;
float mathTime = 16.4;``````

The first math method is Math.Floor();, you put the number you want in the parathases and end it with a ; and it rounds down

`` emptyItem = Math.Floor(mathTime);``

Now it rounds it down the result is 16

And of course now for the round up, here you use Math.Ceiling();
emptyItem = Math.Ceiling(mathTime);
Now it rounds up and the result is 17

Now for Math.Min() and Math.Max() the math.min finds gets the lowest of 2 numbers and math.max gets the biggest. seperate the 2 numbers with a ,
Math.Min(1,6)
returns 1 and Math.Max(1,6)
returns 6

Now for Math.Sqrt() and Math.Cbrt() you put the number into the parathases and it gets the square root or cube root Math.Round() rounds it may not work in replit
Math.Sqrt(9); returns 3
Math.Cbrt(8); returns 2
Math.Round(23.5); returns 24

Math.Abs() returns the absolute value of a number
Math.Abs(-5) returns 5

Math.Pow() puts the 1st number you enter to the 2nd number you enter, seperate with a ,
Math.Pow(2,3) returns 8

Math.Exp() is e to the exponent of a number and Math.E is e times a number

`` Math.Sin(), Math.Sinh(), Math.Tan(), Math.Tanh(), Math.Cos(), Math.Cosh(), and Math.Log()``

is a number times those trig functions

now for basic math, + is plus - is minus * is times and / is division and % returns the remainder

and while I have time here is a full \ tutorial

you have seen the

\
before right? Well I am hear to teach what what they mean, starting with

\n
it creates a new lines, next the

\t
it creates a tab, the

\b
deletes the character before it, and finaly the

\r
takes the word behind it, and deletes the amount of characters it is from the front and then brings it to the front, I hope this was helpful and I'll see you next time.

example code for \r

``Console.WriteLine("Hello \ryou);``

output: