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 possible division by zero error #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daiwai
Copy link

@daiwai daiwai commented Sep 30, 2018

If for some reason the timestamp delta is zero, presumably because the
check has been called twice at the exact same time, various rate
calculations cause a division by zero error.

We now check for zero in delta_timestamp and assume a rate of 0 for the
corresponding rate as a zero delta_timestamp implies no time has passed
so the value for which the rate per time is being calculated could not
have changed either.

This might partly fix #17 although there are more ratios, that don't divide by delta_timestamp but some other value.

If for some reason the timestamp delta is zero, presumably because the
check has been called twice at the exact same time, various rate
calculations caused a division by zero error.

We now check for zero in delta_timestamp and assume a rate of 0 for the
corresponding rate as a zero delta_timestamp implies no time has passed
so the value for which the rate per time is being calculated could not
have changed either.
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.

Illegal division by zero
1 participant