The rational utility functions allow easy manipulation of rational numbers.
◆ mmal_rational_add()
Add 2 rational numbers. It is assumed that both input rational numbers are in their simplest form.
- Parameters
-
a | First operand |
b | Second operand |
- Returns
- a + b
◆ mmal_rational_divide()
Divide 2 rational numbers. It is assumed that both input rational numbers are in their simplest form.
- Parameters
-
a | First operand |
b | Second operand |
- Returns
- a / b
◆ mmal_rational_equal()
Test 2 rational numbers for equality.
- Parameters
-
a | First operand |
b | Second operand |
- Returns
- true if equal
◆ mmal_rational_from_fixed_16_16()
Convert a signed 32-bit Q16 number to a rational number.
- Parameters
-
fixed | Signed 32-bit Q16 number to convert |
- Returns
- Rational number
◆ mmal_rational_multiply()
Multiply 2 rational numbers. It is assumed that both input rational numbers are in their simplest form.
- Parameters
-
a | First operand |
b | Second operand |
- Returns
- a * b
◆ mmal_rational_simplify()
Reduce a rational number to it's simplest form.
- Parameters
-
rational | Rational number to simplify |
◆ mmal_rational_subtract()
Subtract 2 rational numbers. It is assumed that both input rational numbers are in their simplest form.
- Parameters
-
a | First operand |
b | Second operand |
- Returns
- a - b
◆ mmal_rational_to_fixed_16_16()
Convert a rational number to a 32-bit signed Q16 number. Saturation will occur for rational numbers with an absolute value greater than 32768.
- Parameters
-
rational | Rational number to convert |
- Returns
- 32-bit signed Q16 number