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

Question about ticks calculation #552

Open
jmelas opened this issue Feb 19, 2025 · 5 comments
Open

Question about ticks calculation #552

jmelas opened this issue Feb 19, 2025 · 5 comments
Assignees

Comments

@jmelas
Copy link

jmelas commented Feb 19, 2025

DWORD ticks = (DWORD) (((position - m_StartTime) / m_qpcFrequency) * 1000.0);

this does an integer division (with truncation) and converts to double after that:
DWORD ticks = (DWORD) (((position - m_StartTime) / m_qpcFrequency) * 1000.0);

was this the intent (no truncation):
DWORD ticks = (DWORD) ((position - m_StartTime) * 1000.0 / m_qpcFrequency);

if not then why not skip converting to double (might be faster)
DWORD ticks = (DWORD) (((position - m_StartTime) / m_qpcFrequency) * 1000);

@Psychlist1972
Copy link
Contributor

@garydan42 as I'm not sure if this is net new code, or was lifted from the original WinMM port implementation.

@garydan42
Copy link
Collaborator

Good catch, should do the calculation without truncation.

@jmelas
Copy link
Author

jmelas commented Feb 24, 2025

Can I submit a PR for this? If yes do you want a new function, a new macro, or just inplace fixes? (the truncation occurs in several lines)

@Psychlist1972
Copy link
Contributor

Psychlist1972 commented Feb 24, 2025

Can I submit a PR for this? If yes do you want a new function, a new macro, or just inplace fixes? (the truncation occurs in several lines)

Happy to have a PR if you want to submit one. Create a macro and submit a PR. :)

Thanks!

@jmelas
Copy link
Author

jmelas commented Feb 25, 2025

Thanks PR ready!
#559

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

No branches or pull requests

3 participants