# «Eps» (Решение)

## Ответ

```
0.1 + 0.2 != 0.3
```

## Объяснение

Числа типа `Double` представляются согласно спецификации IEEE 754 и хранятся в 64-разрядном бинарном формате. К сожалению, многие десятичные нецелые числа невозможно представить в таком формате, что часто сказывается при выполнении арифметических операций над числами с плавающей запятой:

```csharp
// Displays '5.5511151231257827E-17'
Console.WriteLine("{0:R}", 0.1+0.2-0.3);
```

Лучше всего сравнивать `double`-числа с указанием точности сравнения. Пример:

```csharp
public static bool IsEqual(double a, double b, double eps = 1e-9)
{
    return Math.Abs(a - b) < eps;
}
```

## Ссылки

* [0.30000000000000004.com](http://0.30000000000000004.com/)

[Задача](/problembookdotnet/ru/math/eps-p.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andreyakinshin.gitbook.io/problembookdotnet/ru/math/eps-s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
