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

Potentially incorrect function ceil_divide_signed #2005

Open
chungwong opened this issue Jan 5, 2024 · 0 comments
Open

Potentially incorrect function ceil_divide_signed #2005

chungwong opened this issue Jan 5, 2024 · 0 comments

Comments

@chungwong
Copy link

Application Version
Versions including this commit 3b34b69277

It looks like this function is logically incorrect?

inline unsigned int ceil_divide_signed(int dividend, int divisor) //!< Return dividend divided by divisor rounded up towards positive infinity.
{
    return (dividend / divisor) + (dividend * divisor > 0 ? 1 : 0);
}

// it returns 31 instead of 30
ceil_divide_signed(90, 3);

Is this beahviour expected?

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

1 participant