Fixed-point Library
1.10.1¶
#include <std/fxpt.pat>
Functions¶
std::fxpt::to_float(fixed fxt, u32 precision) -> double
1.10.1¶
Converts a fixed point number “fxt” with a precision of “precision” bits into a floating point number
Parameter |
Description |
---|---|
|
Fixed point number |
|
Bits of precision |
|
Floating point representation of |
std::fxpt::to_fixed(double flt, u32 precision) -> fixed
1.10.1¶
Converts a floating point number “flt” into a fixed point number with a precision of “precision” bits
Parameter |
Description |
---|---|
|
Floating point number |
|
Bits of precision |
|
Fixed point representation of |
std::fxpt::change_precision(fixed value, u32 start_precision, u32 end_precision) -> fixed
1.10.1¶
Converts a fixed point number “value” with a precision of “start_precision” bits into a fixed point number with a precision of “end_precision” bits
Parameter |
Description |
---|---|
|
Fixed point number |
|
Bits of precision of |
|
Bits of precision of the result value |
|
Fixed point number with adjusted precision |
std::fxpt::add(fixed a, fixed b, u32 precision) -> fixed
1.10.1¶
Performs a fixed point addition of values “a” and “b” with a precision of “precision” bits
Warning
Both a
and b
need to have the same precision
Parameter |
Description |
---|---|
|
Left operand |
|
Right operand |
|
Bits of precision of both |
|
Result of |
std::fxpt::subtract(fixed a, fixed b, u32 precision) -> fixed
1.10.1¶
Performs a fixed point subtraction of values “a” and “b” with a precision of “precision” bits
Warning
Both a
and b
need to have the same precision
Parameter |
Description |
---|---|
|
Left operand |
|
Right operand |
|
Bits of precision of both |
|
Result of |
std::fxpt::multiply(fixed a, fixed b, u32 precision) -> fixed
1.10.1¶
Performs a fixed point multiplication of values “a” and “b” with a precision of “precision” bits
Warning
Both a
and b
need to have the same precision
Parameter |
Description |
---|---|
|
Left operand |
|
Right operand |
|
Bits of precision of both |
|
Result of |
std::fxpt::divide(fixed a, fixed b, u32 precision) -> fixed
1.10.1¶
Performs a fixed point division of values “a” and “b” with a precision of “precision” bits
Warning
Both a
and b
need to have the same precision
Parameter |
Description |
---|---|
|
Left operand |
|
Right operand |
|
Bits of precision of both |
|
Result of |