As the base 10 logarithm of 1000 is 3 you might expect `Math::log(1000, 10)` to return `3`. Instead it returns `2.9999999999999996`.

This is due to the fact floats in Ruby are not exact numbers as discussed for example [here](https://stackoverflow.com/a/38702825/2799887):

> 
> Float isn't an exact number representation, as stated in the [ruby
>  docs](http://ruby-doc.org/core-2.2.0/Float.html):
> 
> 
> 
> > 
> > Float objects represent inexact real numbers using the native architecture's double-precision floating point representation.
> > 
> > 
> > 
> 
> 
> This not ruby fault, as floats can only be represented by a fixed
>  number of bytes and therefor cannot store decimal numbers correctly.
> 
> 
> Alternatively, you can use ruby [Rational](http://ruby-doc.org/core-2.2.0/Rational.html) or [BigDecimal](http://ruby-doc.org/stdlib-1.9.3/libdoc/bigdecimal/rdoc/BigDecimal.html)
> 
> 
> 

Sadly when calling `Math::log(BigDecimal('1000'), BigDecimal('10'))` the result is exactly the same. Same goes for `Math::log(Rational('1000'), Rational('10'))`. There is also a `BigMath::log` which [does something completely different](https://ruby-doc.org/stdlib-2.5.1/libdoc/bigdecimal/rdoc/BigMath.html#method-c-log).

Now the big question is: how can we calculate the base 10 logarithm of 1000 such that we get the exact result: `3`?