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

Money.divide/2 does not work with negative values when count exceeds the absolute amount #236

Open
matthijsqd opened this issue Nov 28, 2024 · 0 comments

Comments

@matthijsqd
Copy link

iex(1)> Money.divide(Money.new(-3, :EUR), 2) # Correct
[%Money{amount: -2, currency: :EUR}, %Money{amount: -1, currency: :EUR}]

iex(2)> Money.divide(Money.new(-3, :EUR), 3) # Correct
[
  %Money{amount: -1, currency: :EUR},
  %Money{amount: -1, currency: :EUR},
  %Money{amount: -1, currency: :EUR}
]

iex(3)> Money.divide(Money.new(-3, :EUR), 4) # Does not add up to -3
[
  %Money{amount: 1, currency: :EUR},
  %Money{amount: 1, currency: :EUR},
  %Money{amount: -1, currency: :EUR},
  %Money{amount: 0, currency: :EUR}
]
@matthijsqd matthijsqd changed the title Money.divide/2 does not work with negative values when count exceeds the absolute amount Money.divide/2 does not work with negative values when count exceeds the absolute amount Nov 28, 2024
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