Please quote when replying.

TomRossi7 wrote in post #970346:
> 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.

I think there are better ways of doing that -- such as using a DECIMAL 
field in the database.  Then no conversion is necessary and the data is 
stored as fixed-point.

Or, if you'd rather store the data as an integral number of pennies 
(though that may have i18n issues -- there are a few currencies, such as 
the Kuwaiti dinar, that are subdivided into 1000, not 100), then a quick 
way would be to normalize the string so that it contains 2 decimal 
places (so "123" would become "123.00"), then drop the decimal point.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
Posted via http://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.

Reply via email to