Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Point Math #3115

Merged
merged 1 commit into from
Jul 10, 2023
Merged

Fixed Point Math #3115

merged 1 commit into from
Jul 10, 2023

Conversation

SBird1337
Copy link
Collaborator

Provides inlined fixed point math operations for Q_4_12 FP format.

Description

Introduces new type ufp_4_12_t for unsigned fixed point numbers in specified format, as well as inlined version of add, sub and multiply.

Refactors battle damage modifier calculations to use the new functions in order to improve readability and performance. (See Discord conversation)

This PR does not alter any of the other usages of FP math.

Discord contact info

Karathan

include/fpmath.h Outdated Show resolved Hide resolved
mrgriffin
mrgriffin previously approved these changes Jul 7, 2023
Copy link
Collaborator

@mrgriffin mrgriffin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, so some minor naming nitpicks and that's it:

  • It would be nice if UQ_4_12 and ufp_4_12_{t,add,sub,multiply} used the same names, but that'd probably mean uq_4_12_{...} rather than renaming UQ_4_12 (so that we don't break uses elsewhere) and idk how you feel about that.
  • add, sub, multiply breaks the pattern for me, what's your feeling about mul instead? Or I suppose subtract 🤔

Regardless, I'm very pleased with this change! It's great that the typedefs are 32-bit :)

@SBird1337
Copy link
Collaborator Author

Looks good to me, so some minor naming nitpicks and that's it:

  • It would be nice if UQ_4_12 and ufp_4_12_{t,add,sub,multiply} used the same names, but that'd probably mean uq_4_12_{...} rather than renaming UQ_4_12 (so that we don't break uses elsewhere) and idk how you feel about that.
  • add, sub, multiply breaks the pattern for me, what's your feeling about mul instead? Or I suppose subtract 🤔

Regardless, I'm very pleased with this change! It's great that the typedefs are 32-bit :)

I think Q_ is fine, even though I think people are usually more familiar with the concept of fixed point and thats what we are calling internally. For the sake of not having to refactor everything else we should probably stick with Q / UQ.

How do we feel about the function names in general. I kind of broke convention with CamelCase which is what we usually do. Same about the types. We do not usually add a _t suffix.

@mrgriffin mrgriffin merged commit d8c8ee1 into rh-hideout:upcoming Jul 10, 2023
@AsparagusEduardo AsparagusEduardo mentioned this pull request Sep 27, 2023
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