From: Fukumoto Atsushi Date: 2003-03-26T16:30:27+09:00 Subject: Re: Newbie question: 9/5=1 ? Paul Brannan wrote: >> On Sat, Mar 22, 2003 at 04:37:40AM +0900, Joel VanderWerf wrote: >> > I guess extension writers should not rely on 1/2 == 0 . >> >> Do you think this is reasonable? >> >> What method should I call if I want integer division? Supposedly, you have to use Kernel.Integer, which uses native conversion if obj is builtin numeric object, otherwise it calls obj.to_int (if obj responds to to_int, in Ruby 1.7 or later) or obj.to_i (if obj does not respond to to_int, or Ruby version is older than 1.7). For example, Rational class has Rational#to_i, which hides the call of Integer#div. FUKUMOTO Atsushi fukumoto@imasy.or.jp