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

Add integer division method Num.quo #1148

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

PureFox48
Copy link
Contributor

As far back as #127 @munificent admitted that an integer division operator was a 'missing piece' in Wren's treatment of integers as it was tedious having to write (a/b).truncate all the time.

I opened a discussion about this in #907 but it was decided there was no suitable symbol available. This left the possibility of adding an instance method to the Num class: a.div(b) or a.quo(b) instead and I felt that the latter was preferable as it was more suggestive of integer division.

Although I decided to close the issue at the time, after two more years tedium of having to write (a/b).truncate I've concluded that a.quo(b) would be a sensible 'best effort' for this, particularly if we implement it in C to maximize performance. Hence the reason for this PR.

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.

None yet

1 participant