#### Topic: Rails(/Ruby?) Rounds from 97.66 -> 97

Hello! I am calculating the average of a column from the DB and it's all dandy and stuff, but now I want to go from for example xx.xxxxxx -> xx.xx. This is what I'm doing:

`average = @user.grades.calculate('avg', 'mark', :conditions => "include_overall = TRUE")@average = (average * 100).round / 100`

Now, the average from the database is exactly "97.6667", so it should become 97.66, no? No. It just becomes 97 I think this has something to do with Ruby, and not with Rails. Any ideas guys?

#### Re: Rails(/Ruby?) Rounds from 97.66 -> 97

You are dividing my 100, an integer.  Divide by 100.0, and you will see different behavior.

BrewControl.com - Brewery and Brewpub management powered by RoR

#### Re: Rails(/Ruby?) Rounds from 97.66 -> 97

Ah, thanks a lot. Sometimes I love how picky Rails is, and sometimes I hate it.

#### Re: Rails(/Ruby?) Rounds from 97.66 -> 97

Well, that's actually Ruby, not Rails.  IIRC, Java has the same rules for mixing integer and float math.

BrewControl.com - Brewery and Brewpub management powered by RoR