fxpt
Library for doing arithmetic with fixed point numbers and converting them from/to floating point numbers.
Types
std::fxpt::fixed
std::fxpt::fixed
A fixed point value
Functions
std::fxpt::to_float
std::fxpt::to_float
Converts a fixed point value into a floating point value
fxt
: The fixed point value to convertprecision
: The bits of precision the new value should havereturn
: The floating point representation of fxt
std::fxpt::to_fixed
std::fxpt::to_fixed
Converts a floating point value into a fixed point value
flt
: The floating point value to convertprecision
: The bits of precision the new value should havereturn
: The fixed point representation of flt
std::fxpt::change_precision
std::fxpt::change_precision
Changes the number of bits used to represent the decimal part of the given fixed point number
value
: The fixed point value to convertstart_precision
: The current number of bits usedend_precision
: The new number of bits usedreturn
:value
as a new fixed point number withend_precision
bits of precision
std::fxpt::add
std::fxpt::add
Adds two fixed point numbers with a given precision together
a
: First fixed point numberb
: Second fixed point numberprecision
: The precision ofa
andb
return
: Result of the addition ofa
andb
std::fxpt::subtract
std::fxpt::subtract
Subtracts two fixed point numbers with a given precision together
a
: First fixed point numberb
: Second fixed point numberprecision
: The precision ofa
andb
return
: Result of the subtraction ofa
andb
std::fxpt::multiply
std::fxpt::multiply
Multiplies two fixed point numbers with a given precision together
a
: First fixed point numberb
: Second fixed point numberprecision
: The precision ofa
andb
return
: Result of the multiplication ofa
andb
std::fxpt::divide
std::fxpt::divide
Divides two fixed point numbers with a given precision together
a
: First fixed point numberb
: Second fixed point numberprecision
: The precision ofa
andb
return
: Result of the division ofa
andb
Last updated