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

Division for negative number was rounding up #71

Merged
merged 1 commit into from
Jul 8, 2024
Merged

Division for negative number was rounding up #71

merged 1 commit into from
Jul 8, 2024

Conversation

dahlend
Copy link
Collaborator

@dahlend dahlend commented Jul 8, 2024

This is normal behavior for negative numbers on CPUs, but unexpected behavior for math. This required changing the divisions to div_euclid to match the expected behavior.

     let x = -5 / 3;
     assert!(x, -1);

     let y = -5.div_euclid(3); // this is the mathematically expected behavior
     assert!(y, -2);

Fixes #70

Here is sweeping JD back to -1e6 JD, and performing a YMD conversion for each day:
image
image
image

This is now expected behavior.

This is normal behavior for negative numbers on CPUs, but unexpected behavior for math.
This required changing the divisions to `div_euclid` to match the expected behavior.
@dahlend dahlend merged commit 8178651 into main Jul 8, 2024
1 check passed
@dahlend dahlend deleted the fix-time branch July 8, 2024 17:58
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.

Time conversion from JD to YMD is incorrect for some dates
1 participant