Project

General

Profile

Actions

Feature #3289

closed

Division of negative numbers

Added by patrick_thomson (Patrick Thomson) over 14 years ago. Updated almost 7 years ago.

Status:
Rejected
Target version:
[ruby-core:30231]

Description

=begin
The documentation for Numeric (http://www.ruby-doc.org/core/classes/Numeric.html#M000179) states that integer divmod() (and, by extension, /) rounds the quotient towards negative infinity. Python and Tcl behave similarly, while C, Java, bc, and gdb round the quotient towards zero, as is taught in standard arithmetic courses.

Is this a quirk of MRI's implementation, or is it desired Ruby behavior? If so, why?
It's counterintuitive that (-x/y) ≠ -(x/y), and even moreso when (-x/y) = -(x/y) if x or y is a non-integer.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0