Store percents > what kind of column type?

Hi,

Newby question…

I want to store percents, what kind of column type must i use in my
migration file??

remco

On Nov 20, 2007, at 1:49 AM, Remco S. wrote:

Newby question…

I want to store percents, what kind of column type must i use in my
migration file??

That would be either integer or decimal, but the choice would really
depend on how you intend do do the calculations using those numbers.

Do you want to do them as 150 x 0.75 to represent 75%, or do you want
to do them as 150 x (75/100) to represent 75%.

The former is more comvenient for calculations, but less convenient
for displaying (since most people want 75 and not 0.75 for display
purposes). The latter is the opposite.

So, you pick which version, and choose a columne type that is suitable.

– gw (www.railsdev.ws)

Is this for a class? If so, I’m quite jealous :slight_smile:

Anyhow, I suggest decimal/real as it will be more expedient for coding
purposes. If the output is weird, like:

rate: 0.3333333333333333333

when the desired output is:

rate 33%

I would call that a minor issue and move on to something else, then fix
it later with some formatting.

-thufir