Question: ```
1.824999999999999.round(2)
# => 1.82
1.82499999999999999.round(2)
# => 1.83

```

I don't understand why the result in the first case is `1.82` and for the latter `1.83`. My desired result is `1.82` for both cases.

Answer: 
As is well known, a floating number in computer has errors. Notice that both numbers that you have are close to `1.825`. In your first case, the number is small enough to be differentiated from `1.825`.

```
1.824999999999999
# => 1.824999999999999

```

In your second case, having enough `9`s makes the value close enough to be considered exactly as `1.825`:

```
1.82499999999999999
# => 1.825

```

Then, when you apply `round`, you get `1.83`.
Floats are notoriously imprecise as sawa and Neil have pointed out.

If this is mainly an issue for testing, you can use [assert\_in\_delta](http://apidock.com/ruby/MiniTest/Assertions/assert_in_delta) if you're using minitest, or [be\_within](https://www.relishapp.com/rspec/rspec-expectations/v/2-3/docs/built-in-matchers/be-within-matcher) with rSpec