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="trans. (T. Onoma), post: 4446191"] On Friday 15 October 2004 07:23 pm, [email]markus@reality.com[/email] wrote: | > puts 0.5.round #=> 1 | > puts sprintf("%.0f", 0.5) #=> 0 | | Both are (IIRC) ISO 31-0 conformant, but one uses ISO 31-0 B.3 rule A | and the other uses ISO 31-0 B.3 rule B. | | That said, one of the rules (the one sprintf uses, to round down | following even digits is an abomination and should be eliminated from the | face of the earth. nnn.nn5 should ALWAYS round up and rounded values | should not be re-rounded (which is what the contrary rule assumes is | happening). Apparently the idea of even vs. odd rounding was to help prevent "inflational" rounding --successive rounding pushing values upward. I think K&R actually supported the idea. I'm not sure how I feel about it. T. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Rounding to X digits
Top