From: Justin Collins Date: 2010-01-23T11:32:30+09:00 Subject: Re: why is rails/ruby automatically rounding to whole numbers. Morgan Morgan wrote: > @wtf= 751 / 750 > > returns 1 in the view > > @wtf= 3 / 750 > > returns 0 in the view > > @wtf= 749 / 750 > > returns 0 in the view. > > > can somebody explain what's going on here. i'm just trying to calculate > percents. > Ruby performs integer division when the numerator and the denominator are both integers. If either is a floating point number, it will perform floating point division. Therefore, simply call .to_f on either side of the division and you will get a floating point number. -Justin