I'm trying to write a basic digit counter (an integer is inputted and the number of digits of that integer is outputted) for positive integers. This is my general formula:

```
dig(x) := Math.floor(Math.log(x,10))

```

I tried implementing the equivalent of `dig(x)` in Ruby, and found that when I was computing `dig(1000)` I was getting 2 instead of 3 because `Math.log` was returning 2.9999999999999996 which would then be truncated down to 2. What is the proper way to handle this problem? (I'm assuming this problem can occur regardless of the language used to implement this approach, but if that's not the case then please explain that in your answer).