Fixed-point variables are implemented using uint variables (
sint8, sint16, sint32
), with hardcoded shift values. MicroC allocates data according to thewordSize
of the variable.
All calls to functions or expressions requiring integer values are done through an
FXP-to-int
cast, including the test-driver/ panel driver. Specifically, the operators “ROUND” and “TRUNC” are called with anFXP-to-int
cast.For example, given a fixed-point variable
fxp_var
, an integer variableint_var
, and the following actions:The generated code is as follows, if you specify fixed-point mode: