Behaviour of round changed?

Peter Hickman <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CALxYQy6oGLHMHm4GXcjoUDj5WTB3bYsYwgrKtvOLdsprVELiYw@mail.gmail.com>
I am moving some algorithms between 1.9.3 and 2.4.2 and found (after much
head scratching)

2.4.2 :001 > 1.015.round(2)
 => 1.02

1.9.3-p551 :001 > 1.015.round(2)
 => 1.01

We are calculating margin prices and round input values to 2 places because
the precision is not needed and it can help with caching

The tests broke :(

Let me see if I understand this, Ruby has changed how basic maths functions
work

Can I trust ceil, floor, truncate or any of the other number related
functions?

Do I need to write tests for the language itself for when I upgrade to a
newer version in the future or should I stick with 1.9.3 for all eternity?

A change at this low a level is almost impossible to speculatively test
for, if I cannot trust the language I am using I cannot trust my code at all

I am now in a position of having to test my code to an excessive degree
because I cannot trust there are not any other changes that will be
triggered on some previously innocent edge case

I am extremely pissed off right now


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.