# Store percents \> what kind of column type?

**URL:** <https://www.ruby-forum.com/t/store-percents-what-kind-of-column-type/120750>\
**Category:** Rails\
**Created:** [November 20, 2007, 10:49am UTC](https://www.ruby-forum.com/t/store-percents-what-kind-of-column-type/120750 "2007-11-20T10:49:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 20, 2007, 10:49am UTC](https://www.ruby-forum.com/t/store-percents-what-kind-of-column-type/120750/1 "2007-11-20T10:49:04Z")

</div>

Hi,

Newby question…

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

remco

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 20, 2007, 11:09am UTC](https://www.ruby-forum.com/t/store-percents-what-kind-of-column-type/120750/2 "2007-11-20T11:09:49Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 20, 2007, 11:15am UTC](https://www.ruby-forum.com/t/store-percents-what-kind-of-column-type/120750/3 "2007-11-20T11:15:39Z")

</div>

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

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
