From: Dave Thomas Date: 2000-06-06T20:51:04-05:00 Subject: [ruby-talk:03139] Re: Is divmod dangerous? matz@netlab.co.jp (Yukihiro Matsumoto) writes: > |Okay, divmod should be change. I vote 13/-4 -> -4 too. > |Generally, > | > | num / den := floor(num "div" den) # "div" in done in the real > | num % den := num - den*(num/den) > > So, you mean making modulo and reminder be same? Python way? How about a compromise? We have two basic methods, Integer#div (the current behavior) and Integer#divz, which truncates towards zero. Associated with these are corresponding modulo routines, #mod (the current behavior) and #modz (which is equivalent to remainder). Then, we have two 'personalities', which are actually just modules. include ZeroTrunc aliases Integer#/ to divz and Integer#% to #modz include SchemeTrunc does the opposite Have ZeroTrunc be the default, but allow people to load SchemeTrunc for the traditional behavior. Library routines which can potentially run in either environment should use the underlying .div and .divz routines. Dave