Skip to main content

MathF

The MathF class provides useful static methods for anything relating to Math with Floats. While most languages have math functions built in, this provides actual Unity/dotnet math functions.

Methods

Method NameReturn TypeParametersDescription
AbsfloatfloatReturns the absolute value of a single-precision floating-point number
AcosfloatfloatReturns the angle whose cosine is the specified number
AcoshfloatfloatReturns the angle whose hyperbolic cosine is the specified number
AsinfloatfloatReturns the angle whose sine is the specified number
AsinhfloatfloatReturns the angle whose hyperbolic sine is the specified number
AtanfloatfloatReturns the angle whose tangent is the specified number
Atan2floatfloat, float OR float2Returns the angle whose tangent is the quotient of two specified numbers
AtanhfloatfloatReturns the angle whose hyperbolic tangent is the specified number
CbrtfloatfloatReturns the cube root of a specified number
CeilingfloatfloatReturns the smallest integral value that is greater than or equal to the specified single-precision floating-point number
CosfloatfloatReturns the cosine of the specified angle
CoshfloatfloatReturns the hyperbolic cosine of the specified angle
ExpfloatfloatReturns e raised to the specified power
FloorfloatfloatReturns the largest integral value less than or equal to the specified single-precision floating-point number
FusedMultiplyAddfloatfloat, float, floatReturns (x * y) + z, rounded as one ternary operation
IEEERemainderfloatfloat, float OR float2Returns the remainder resulting from the division of a specified number by another specified number
LogfloatfloatReturns the natural (base e) logarithm of a specified number
Logfloatfloat, float OR float2Returns the logarithm of a specified number in a specified base.
Log10floatfloatReturns the base 10 logarithm of a specified number
Maxfloatfloat, float OR float2Returns the larger of two single-precision floating-point numbers
Minfloatfloat, float OR float2Returns the smaller of two single-precision floating-point numbers
Powfloatfloat, float OR float2Returns a specified number raised to the specified power
Roundfloatfloat, int, MidpointRoundingRounds a single-precision floating-point value to a specified number of fractional digits, and rounds midpoint values to the nearest even number
SignfloatfloatReturns an integer that indicates the sign of a single-precision floating-point number
SinfloatfloatReturns the sine of the specified angle
SinCosSinCosfloatReturns the sine and cosine of the specified angle
SinhfloatfloatReturns the hyperbolic sine of the specified angle
SqrtfloatfloatReturns the square root of a specified number
TanfloatfloatReturns the tangent of the specified angle
TanhfloatfloatReturns the hyperbolic tangent of the specified angle
TruncatefloatfloatCalculates the integral part of a specified single-precision floating-point number