14.1. math — Math functions and definitions

Source code: src/science/math.h, src/science/math.c

Test code: tst/science/math/main.c

Test coverage: src/science/math.c


Defines

MATH_PI

Functions

float math_radians_to_degrees(float value)

Convert given angle from radians to degrees.

Return
Angle in degrees, or NaN if an error occurred.
Parameters
  • angle: Angle in radians.

float math_degrees_to_radians(float value)

Convert given angle from degrees to radians.

Return
Angle in radians, or NaN if an error occurred.
Parameters
  • angle: Angle in degrees.

int32_t math_log2_fixed_point(uint32_t x, int precision)

Calculate the 2-logarithm of given value in given fixed point precision.

Return
2-logarithm of given value x, in given precision.
Parameters
  • x: Value to calculate the 2-logarithm of.
  • precision: Fixed point precision in the range 1 to 31, inclusive.

int32_t math_ln_fixed_point(uint32_t x, int precision)

Calculate the natural logarithm of given value in given fixed point precision.

Return
Natural logarithm of given value x, in given precision.
Parameters
  • x: Value to calculate the natural logarithm of.
  • precision: Fixed point precision in the range 1 to 31, inclusive.

int32_t math_log10_fixed_point(uint32_t x, int precision)

Calculate the 10-logarithm of given value in given fixed point precision.

Return
10-logarithm of given value x, in given precision.
Parameters
  • x: Value to calculate the 10-logarithm of.
  • precision: Fixed point precision in the range 1 to 31, inclusive.