On Sun, Mar 31, 2013 at 2:14 AM, Julian Leviston <julian / coretech.net.au>wrote:

> On 31/03/2013, at 5:36 PM, Josh Cheek <josh.cheek / gmail.com> wrote:
>
> Might also add floating point number imprecision.
> $ ruby -e 'p 7.01 - 7'
> 0.009999999999999787
>
>
> Really? That's got nothing to do with Ruby! That's computers! :)
>
> Julian.
>


It's IEEE floating point math.

It does have to do with Ruby, Ruby could have implemented literal numbers
with decimal points using Rational or BigDecimal instead of Float. Both are
in the stdlib (plus, there are gems like flt)

require 'bigdecimal'
require 'bigdecimal/util'
('7.01'.to_f - '7.00'.to_f)           # => 0.009999999999999787
('7.01'.to_r - '7.00'.to_r)           # => (1/100)
('7.01'.to_d - '7.00'.to_d).to_digits # => "0.01"