From: Brian Candler Date: 2010-11-25T01:09:13+09:00 Subject: Re: Ruby 1.8 vs 1.9 Phillip Gawlowski wrote in post #963602: > Convert your strings to UTF-8 at all times, and you are done. But that basically is my point. In order to make your program comprehensible, you have to add extra incantations so that strings are tagged as UTF-8 everywhere (e.g. when opening files). However this in turn adds *nothing* to your program or its logic, apart from preventing Ruby from raising exceptions. >> Well, IEEE floating point is a well-established standard that has been >> around for donkeys years, so I think it's reasonable to follow it. > > Every natural number is an element of the set of rational numbers. For > all intents and purposes, 0 == 0.0 in mathematics (unless you limit > the set of numbers you are working on to natural numbers only, and > let's just ignore irrational numbers for now). And since the 0 is > around for a bit longer than the IEEE, and the rules of math are > taught in elementary school (including "you must not and cannot divide > by zero"), Ruby exhibits inconsistent behavior for pretty much anyone > who has a little education in maths. Maths and computation are not the same thing. Is there anything in the above which applies only to Ruby and not to floating point computation in another other mainstream programming language? Yes, there are gotchas in floating point computation, as explained at http://docs.sun.com/source/806-3568/ncg_goldberg.html These are (or should be) well understood by programmers who feel they need to use floating point numbers. If you don't like IEEE floating point, Ruby also offers BigDecimal and Rational. If Ruby were to implement floating point following some different set of rules other than IEEE, that would be (IMO) horrendous. The point of a standard is that you only have to learn the gotchas once. -- Posted via http://www.ruby-forum.com/.