Decimal numbers pain

2 views
Skip to first unread message

Fernando Perez

unread,
Sep 4, 2010, 5:20:50 PM9/4/10
to rubyonra...@googlegroups.com
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?
--
Posted via http://www.ruby-forum.com/.

Greg Willits

unread,
Sep 4, 2010, 5:57:19 PM9/4/10
to rubyonra...@googlegroups.com
> 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]

Fernando Perez

unread,
Sep 4, 2010, 6:16:22 PM9/4/10
to rubyonra...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages