Skip to content

Conversation

@jakobj
Copy link
Contributor

@jakobj jakobj commented Jan 14, 2026

This PR introduces rounding to the fixedpoint type (currently only used in mul) and functions to up-/down-cast to other fixedpoint types with different bitwidths. I've also fixed some whitespace issues.

@rmanohar currently this requires the user to define a global variable FXP_ROUNDING_MODE when using the fixedpoint library, e.g., via commandline flags. not sure this is the best solution, but it works for me.

@jakobj jakobj changed the title Add rounding and casting functions Add rounding and casting functions to math::fxp Jan 14, 2026
@rmanohar
Copy link
Member

rmanohar commented Jan 20, 2026

The global is a bit problematic, since a normal user that imports math will just get an error about a missing global. One option would be to add it as a template parameter with a default value. We probably should have a discussion about other options for this.

@jakobj
Copy link
Contributor Author

jakobj commented Jan 20, 2026

right, i thought they'd only get the error when importing fxp, so this solution is suboptimal (unless we remove fxp from __all__).
i agree a template parameter would be nicer (might even the best option?). how would that work with the fixpoint type? my naive approach to using template<> on methods failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants