Project

General

Profile

Feature #3289

Updated by mame (Yusuke Endoh) about 12 years ago

=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 
 

Back