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
Rounding to X digits
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="James Edward Gray II, post: 4445989"] You're looking for sprintf(): sprintf "%.2f", 39.456789 # => 39.46 The ri docs for sprintf() will explain the format string options. It also has a cousin, printf() that can used as the data is sent to some IO object. Finally, the String class allows a shortcut: "%.2f" % 39.456789 # => 39.46 Hope that helps. James Edward Gray II [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Rounding to X digits
Top