Module: Toybox.Math
Overview
The Math Module provides various math methods available for use by Apps.
Classes Under Namespace
Classes: Filter, FirFilter, IirFilter
Constant Summary
Constant Variables
| Type | Name | Value | Since | Description |
|---|---|---|---|---|
| Type | E | 2.7182818284590452354 | API Level 1.0.0 |
32-bit floating point representation of E |
| Type | PI | 3.14159265358979323846 | API Level 1.0.0 |
32-bit floating point representation of PI |
Instance Method Summary collapse
-
abs(value as Lang.Numeric) as Lang.Numeric
Get the absolute value of a value.
-
acos(x as Lang.Numeric) as Lang.Decimal
Get the arc cosine of an angle.
-
asin(x as Lang.Numeric) as Lang.Decimal
Get the arc sine of an angle.
-
atan(x as Lang.Numeric) as Lang.Decimal
Get the arc tangent of an angle.
-
atan2(y as Lang.Numeric, x as Lang.Numeric) as Lang.Decimal
Get the arc tangent of y/x in radians.
-
ceil(x as Lang.Numeric) as Lang.Numeric
Compute the ceiling of a value.
-
cos(x as Lang.Numeric) as Lang.Decimal
Get the cosine of an angle.
-
floor(x as Lang.Numeric) as Lang.Numeric
Compute the floor of a value.
-
ln(x as Lang.Numeric) as Lang.Decimal
Get natural logarithm of a value.
-
log(x as Lang.Numeric, base as Lang.Numeric) as Lang.Decimal
Get logarithm of a value using the specified base.
-
max(a as Lang.Numeric, b as Lang.Numeric) as Lang.Numeric
Get the maximum of two values.
-
mean(data as Lang.Array<Lang.Numeric>) as Lang.Double
Get the arithmetic mean (average) of an array of data.
-
min(a as Lang.Numeric, b as Lang.Numeric) as Lang.Numeric
Get the minimum of two values.
-
mode(data as Lang.Array<Lang.Object>) as Lang.Object
Get the most common value found in an array of data.
-
pow(x as Lang.Numeric, y as Lang.Numeric) as Lang.Decimal
Calculate x to the power of y.
-
rand() as Lang.Number
Returns a pseudo-random Number.
-
round(x as Lang.Numeric) as Lang.Numeric
Round a value.
-
sin(x as Lang.Numeric) as Lang.Decimal
Get the sine of an angle.
-
sqrt(x as Lang.Numeric) as Lang.Decimal
Calculate the square root of a value.
-
srand(seed as Lang.Number) as Void
Seed the random number generator.
-
stdev(data as Lang.Array<Lang.Numeric>, xbar as Lang.Double or Null) as Lang.Double
Get the standard deviation of a sample of population data.
-
tan(x as Lang.Numeric) as Lang.Decimal
Get the tangent of an angle.
-
toDegrees(x as Lang.Numeric) as Lang.Decimal
Convert an angle from radians to degrees.
-
toRadians(x as Lang.Numeric) as Lang.Decimal
Convert an angle from degrees to radians.
-
variance(data as Lang.Array<Lang.Numeric>, xbar as Lang.Numeric or Null) as Lang.Double
Get the sample variance of an array of data.
Instance Method Details
abs(value as Lang.Numeric) as Lang.Numeric
Get the absolute value of a value
acos(x as Lang.Numeric) as Lang.Decimal
Get the arc cosine of an angle.
asin(x as Lang.Numeric) as Lang.Decimal
Get the arc sine of an angle.
atan(x as Lang.Numeric) as Lang.Decimal
Get the arc tangent of an angle.
atan2(y as Lang.Numeric, x as Lang.Numeric) as Lang.Decimal
Get the arc tangent of y/x in radians.
ceil(x as Lang.Numeric) as Lang.Numeric
Compute the ceiling of a value.
cos(x as Lang.Numeric) as Lang.Decimal
Get the cosine of an angle.
floor(x as Lang.Numeric) as Lang.Numeric
Compute the floor of a value.
ln(x as Lang.Numeric) as Lang.Decimal
Get natural logarithm of a value
log(x as Lang.Numeric, base as Lang.Numeric) as Lang.Decimal
Get logarithm of a value using the specified base
max(a as Lang.Numeric, b as Lang.Numeric) as Lang.Numeric
Get the maximum of two values
mean(data as Lang.Array<Lang.Numeric>) as Lang.Double
Get the arithmetic mean (average) of an array of data.
min(a as Lang.Numeric, b as Lang.Numeric) as Lang.Numeric
Get the minimum of two values
mode(data as Lang.Array<Lang.Object>) as Lang.Object
Get the most common value found in an array of data.
pow(x as Lang.Numeric, y as Lang.Numeric) as Lang.Decimal
Calculate x to the power of y.
rand() as Lang.Number
Returns a pseudo-random Number. Use the srand() function to seed the random number generator.
round(x as Lang.Numeric) as Lang.Numeric
Round a value.
sin(x as Lang.Numeric) as Lang.Decimal
Get the sine of an angle.
sqrt(x as Lang.Numeric) as Lang.Decimal
Calculate the square root of a value.
srand(seed as Lang.Number) as Void
Seed the random number generator.
srand() does not return any value.
stdev(data as Lang.Array<Lang.Numeric>, xbar as Lang.Double or Null) as Lang.Double
Get the standard deviation of a sample of population data.
tan(x as Lang.Numeric) as Lang.Decimal
Get the tangent of an angle.
toDegrees(x as Lang.Numeric) as Lang.Decimal
Convert an angle from radians to degrees.
toRadians(x as Lang.Numeric) as Lang.Decimal
Convert an angle from degrees to radians.
variance(data as Lang.Array<Lang.Numeric>, xbar as Lang.Numeric or Null) as Lang.Double
Get the sample variance of an array of data.
Returns the sample variance with Bessel's correction.