Math
Overview
The Math module provides standard mathematical functions and constants. Functions operate on float unless otherwise noted.
Constants
Math.PI // 3.141592653589793Math.E // 2.718281828459045Basic Functions
Math.Abs(-5.0) // 5.0Math.AbsInt(-3) // 3Math.Sqrt(9.0) // 3.0Math.Pow(2.0, 10.0) // 1024.0Math.PowInt(2, 10) // 1024Rounding
Math.Floor(3.7) // 3.0Math.Ceil(3.2) // 4.0Math.Round(3.5) // 4.0Min and Max
Math.Min(3.0, 7.0) // 3.0Math.Max(3.0, 7.0) // 7.0Math.MinInt(3, 7) // 3Math.MaxInt(3, 7) // 7Trigonometry
All angles are in radians:
Math.Sin(Math.PI / 2.0) // 1.0Math.Cos(0.0) // 1.0Example
float Hypotenuse(float a, float b){ return Math.Sqrt(Math.Pow(a, 2.0) + Math.Pow(b, 2.0));}
float h = Hypotenuse(3.0, 4.0);Console.WriteLine($"Hypotenuse: {h}");