wren icon indicating copy to clipboard operation
wren copied to clipboard

Add integer division method Num.quo

Open PureFox48 opened this issue 1 year ago • 0 comments

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.

PureFox48 avatar Mar 05 '23 10:03 PureFox48