I have currency information that I plan to store as an integer --
ironically to avoid issues like this. The user input will always be
in a decimal form. I'm thinking I will just do this ('291.15'.to_f *
100).round instead. That should round out any of the weird float
issues.
On Dec 23, 12:51 pm, Marnen Laibow-Koser <[email protected]> wrote:
> Please quote when replying.
>
> Jeff Burlysystems wrote in post #970344:
>
> > Or just change the way you calculate to get at the level of accuracy
> > that you want/need:
>
> > irb> ("291.15".to_f * 1000.0).to_i/10
> > => 29115
>
> That's incredibly silly IMHO. Besides, it will not always be the same
> for all values, will it? I think BigDecimal is the right answer here.
>
>
>
> > Jeff
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> [email protected]
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.