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

add DivRoundClosest function, formatting #1786

Merged
merged 2 commits into from
Jul 13, 2024

Conversation

rfomin
Copy link
Collaborator

@rfomin rfomin commented Jul 12, 2024

src/doomtype.h Outdated

#define BETWEEN(l, u, x) ((l) > (x) ? (l) : (x) > (u) ? (u) : (x))

#define DIV_ROUND_CLOSEST(n, d) \
Copy link
Owner

Choose a reason for hiding this comment

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

Is this something like (int)round(x, 2)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but for integer division. See https://stackoverflow.com/a/18067292

Copy link
Owner

@fabiangreffrath fabiangreffrath left a comment

Choose a reason for hiding this comment

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

Cool, thanks!

Will we need this for this code as well?

src/r_main.c
592:  scaledviewx = (video.unscaledw - scaledviewwidth) / 2;

@rfomin
Copy link
Collaborator Author

rfomin commented Jul 13, 2024

Will we need this for this code as well?

We may need it in many places. I will test it later.

@rfomin rfomin changed the title add DIV_ROUND_CLOSEST macro, formatting add DivRoundClosest function, formatting Jul 13, 2024
@rfomin rfomin merged commit c447781 into fabiangreffrath:master Jul 13, 2024
8 checks passed
@rfomin rfomin deleted the div_round_closest branch July 13, 2024 02:07
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