KEMBAR78
Allow calling Rational#to_d without arguments by fsateler · Pull Request #421 · ruby/bigdecimal · GitHub
Skip to content

Conversation

@fsateler
Copy link
Contributor

@fsateler fsateler commented Sep 5, 2025

Then the precision would be 0, just like with Float.

See #276 (comment)

@tompng
Copy link
Member

tompng commented Sep 6, 2025

The change for Rational looks good 👍
Can you also modify Complex#to_d' s document and implementation?
I think (1/3r + 0i).to_d should be allowed just like (1/3r).to_d

@fsateler fsateler force-pushed the feature/rational-to-d branch 2 times, most recently from 9f666c4 to dba4c57 Compare September 8, 2025 21:06
@fsateler
Copy link
Contributor Author

fsateler commented Sep 8, 2025

Done! I also documented the error if the imaginary part is not zero

Then the precision would be 0, just like with Float.

Apply the same change to Complex, which had a different validation
Copy link
Member

@tompng tompng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@tompng tompng merged commit d9af278 into ruby:master Sep 9, 2025
81 checks passed
@fsateler fsateler deleted the feature/rational-to-d branch September 9, 2025 11:44
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.

2 participants