Skip to content

Cast divmod quotient to int #312

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Cast divmod quotient to int #312

wants to merge 2 commits into from

Conversation

mrzasa
Copy link
Contributor

@mrzasa mrzasa commented Feb 4, 2025

Changes

Cast the quotient of divmod to integer.

It seems to be reasonable to make this change on the last step - just before returning to the caller, not inside BigDecimal_DoDivmod. BigDecimal_DoDivmod is widely used in other places of the gem and changing its inteface would be cumbersome and risky.

Rationale

Float and Integer return an Integer as the first result of #divmod.

 pry(main)> 10.0.divmod(3)
=> [3, 1.0]
 pry(main)> 10.divmod(3)
=> [3, 1]

Fixes #262
Blocked by #313

@mrzasa mrzasa marked this pull request as ready for review February 4, 2025 22:07
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.

I would expect BigDecimal#divmod to return type [Int, BigDecimal] (like Integer#divmod, Float#divmod)
1 participant