Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
when 1.6 != 1.6? -- newbie
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Mark Hubbart, post: 4466645"] Here's a nice page that with a self-explanitory title: "What Every Computer Scientist Should Know About Floating-Point Arithmetic" <[URL]http://docs.sun.com/source/806-3568/ncg_goldberg.html[/URL]> The way money is usually handled is to either use integers for pennies, or use a separate money class which stores money in that way. A nice thing about doing this in Ruby is that once you create your money class, you can add helper methods to Numeric: class Numeric def cents Money.new(self.round) end def dollars Money.new((self*100).round) end end 23.cents #==> $0.23 23.50.dollars #==> $23.50 cheers, Mark [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
when 1.6 != 1.6? -- newbie
Top