Comments on: 9 New Features in Ruby 2.4 http://www.blackbytes.info/2016/12/new-ruby-features/ Ruby Programming Tutorials Fri, 09 Dec 2016 13:49:23 +0000 hourly 1 https://wordpress.org/?v=4.6.1 By: Jesus Castello http://www.blackbytes.info/2016/12/new-ruby-features/#comment-570 Fri, 09 Dec 2016 13:49:23 +0000 http://www.blackbytes.info/?p=3968#comment-570 Thank you 🙂

]]>
By: Jesus Castello http://www.blackbytes.info/2016/12/new-ruby-features/#comment-569 Fri, 09 Dec 2016 13:49:12 +0000 http://www.blackbytes.info/?p=3968#comment-569 Thanks for your explanation 🙂

]]>
By: Philippe Van Eerdenbrugghe http://www.blackbytes.info/2016/12/new-ruby-features/#comment-568 Fri, 09 Dec 2016 10:42:08 +0000 http://www.blackbytes.info/?p=3968#comment-568 the reason is to prevent biasing numbers on average upward or downward.

For example if you have a list of numbers that include a lot of x.5 and you were to round all these upward, the average magnitude of the list would also shift upward. Likewise if you round downward, downward.

By rounding to the nearest even number these would balance out, given enough samples.

http://mathematica.stackexchange.com/a/2120/45178

]]>
By: Curt Sampson http://www.blackbytes.info/2016/12/new-ruby-features/#comment-567 Fri, 09 Dec 2016 07:41:39 +0000 http://www.blackbytes.info/?p=3968#comment-567 It avoids “sign bias” that can make some calculations on rounded numbers head significantly away from zero compared to the same calculations on unrounded numbers or rounded versions of numbers that are very close. For example looking at the list [1.5, 2.5, 3.5, 4.5]:

The average of those numbers is 3.
The average of those numbers after rounding each towards even is 3.
If you subtract 0.00001 from each number and then round them away from zero, the average is 3.

However:
* The average of those numbers after rounding each away from zero is 3.5.

]]>
By: Ben Cullen-Kerney http://www.blackbytes.info/2016/12/new-ruby-features/#comment-566 Fri, 09 Dec 2016 07:05:57 +0000 http://www.blackbytes.info/?p=3968#comment-566 I wasn’t familiar with this rule either, until the calculator app PCalc temporarily removed it a few months ago: http://leancrew.com/all-this/2016/10/well-rounded/.

]]>