Re: setting the number of decimal points in a float

Perhaps what you want is a "Decimal" type? This is added to Rails in 1.2 and edge so you can specify a "decimal" type column in the database. This allows you to specify how many decimal places you want. See this post for details.

Re: setting the number of decimal points in a float

The code is in my application helper and so I could not use the printf, and I am not on rails 1.2 quite yet, so I came up with an intermediate solution and learned a bit more about regular expressions in the process.

What I had was a column in a table where the values were:0.0-0.25-0.5-0.75-1.0-1.25....-6.0

As you can see they don't line up nicely so I used a regular expression to find everything that had a '.0' or '.5' in it, and then append 0 to that. This application will never have values ending in anything other than .0, .25, .5, or .75, so I won't have to worry about it getting messy in the future.

Re: setting the number of decimal points in a float

dahuk wrote:

The code is in my application helper and so I could not use the printf, and I am not on rails 1.2 quite yet, so I came up with an intermediate solution and learned a bit more about regular expressions in the process.