96
b0ni
8y

Ruby 2.3
1.5.round == 2
2.5.round == 3

Ruby 2.4
1.5.round == 2
2.5.round == 2

Have Fun!

Comments
  • 4
    Wow. I'm dissapointed. Thats gotta be the stupidest thing to do ever. This will break so many systems and make people pull their hair. Its not intuitive at all.
  • 3
    @arekxv it's rounding to nearest even. Strategy defined by IEEE 754 standard. It's not so stupid but it's a little bit late to do something like that
  • 0
    Is/was there no way to define a specific rounding mode?
  • 3
    @b0ni I know its IEEE 754, thats not the point. There are standards, but if many people and languages are not using them then why bother to conform to the standard like that, especially when it goes against Ruby's philosophy of "It works like you expect it to".
  • 4
    So .NET gives you a way to decide in which way you want to round using the Math.Round(); function with a dedicated parameter.
    Furthermore, you can tell the function how much precision have to be used while rounding (number of decimals)

    Is ruby giving you these kind of options after this major change in rounding?
  • 3
    Sounds like they should use semantic versioning.
  • 18
    Makes sense. 2 is by far the roundest number, so all numbers should round to 2.
  • 0
    Dafaq?! Why :(
  • 2
    That makes we want to cry.
  • 0
    That's not the case actually. From 1.5 if it rounds up, it should be 2. So from 2.5 it should round up as well, but it doesn't because it aims for the closest EVEN number.

    4.5 and 3.5 would both give 4. @thejohnhoffer
  • 0
    @BartBB the fact that there is an excuse for this makes it even worse
  • 0
    So they just went and said fuck math?
  • 4
    It should really round to the next multiple of pi. Then it'd be actually round.
  • 0
    No excuse, I dislike it as much as you do. @slinavipuz
Add Comment