# Decimal numbers pain

**URL:** <https://www.ruby-forum.com/t/decimal-numbers-pain/194422>\
**Category:** Rails\
**Created:** [September 4, 2010, 11:20pm UTC](https://www.ruby-forum.com/t/decimal-numbers-pain/194422 "2010-09-04T23:20:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [September 4, 2010, 11:20pm UTC](https://www.ruby-forum.com/t/decimal-numbers-pain/194422/1 "2010-09-04T23:20:50Z")

</div>

Hi,

What do you guys use to definitely handle decimal numbers? This is  
getting me crazy!

I use BigDecimal, but it craps out of the input number is something like  
“14,53”, Rails transforms it as 14.0

Any solution?

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [September 4, 2010, 11:57pm UTC](https://www.ruby-forum.com/t/decimal-numbers-pain/194422/2 "2010-09-04T23:57:19Z")

</div>

> What do you guys use to definitely handle decimal numbers? This is  
> getting me crazy!
> 
> I use BigDecimal, but it craps out of the input number is something like  
> “14,53”, Rails transforms it as 14.0
> 
> Any solution?

Are you really using the comma in the data?

This IRB session suggests what might be happening (unless there’s a en  
ENV flag that allows the comma?):

> > require ‘bigdecimal’  
> > =\> true
> 
> > x = BigDecimal  
> > =\> BigDecimal
> 
> > x = 14.4564  
> > =\> 14.4564
> 
> > x = 14,4564  
> > =\> [14, 4564]
> 
> >

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [September 5, 2010, 12:16am UTC](https://www.ruby-forum.com/t/decimal-numbers-pain/194422/3 "2010-09-05T00:16:22Z")

</div>

It seems Rails does it a bit differently. Anyway I was able to find a  
solution:

[http://gem-session.com/2010/03/how-to-use-the-comma-as-decimal-separator-in-rails-activerecord-columns-and-text-fields](http://gem-session.com/2010/03/how-to-use-the-comma-as-decimal-separator-in-rails-activerecord-columns-and-text-fields)

–

[http://digiprof.tv](http://digiprof.tv)
