diff --git a/include/fxp.h b/include/fxp.h index 430a453..a5b75f1 100644 --- a/include/fxp.h +++ b/include/fxp.h @@ -21,6 +21,7 @@ typedef int64_t fxp_tmp_t; * FXP conversion functions */ fxp_t fxp_from_int(int32_t v); +int32_t fxp_to_int(fxp_t v); fxp_t fxp_from_float(float v); float fxp_to_float(fxp_t v); diff --git a/src/fxp_conv.c b/src/fxp_conv.c index cd154c6..24abe2f 100644 --- a/src/fxp_conv.c +++ b/src/fxp_conv.c @@ -15,3 +15,8 @@ float fxp_to_float(fxp_t v) return (float)v / (1 << POINTPOS); } +int32_t fxp_to_int(fxp_t v) +{ + return v >> POINTPOS; +} +