From: Johann Hibschman Date: 2001-05-08T06:11:25+09:00 Subject: [ruby-talk:14813] Re: Integer division oddness Mike T Miller writes: > My father pointed out this oddity. > Using integer math, try this on various languages: > -10 / 9 > For ruby, python and tcl you get: -2! > For java, c and gforth you get: -1 IMHO, the ruby and python result is the correct one, although I still don't like it. This is one place where java, c, and gforth are just broken. Things get weird if you were considering "10 / -9" or "-10 / -9", but for "-10 / 9", there is only one right answer, and that's -2. The link you posted gets to the heart of the matter. Luckily, both python and ruby have a divmod function, which makes things quite explicit. Of course, I'd prefer it if "/" produced rationals and forced people to use "div" when they meant div. Integer division just doesn't exist, since the integers are a ring and not a field. Grumble. Grumble. Why can't more languages get this right? --Johann -- Johann Hibschman johann@physics.berkeley.edu