# EXCEL関数 小数計算の誤差と回避方法

## **誤差**

i-ReporterのEXCEL関数機能で小数計算をした結果と、Excel上の計算結果との間に誤差が発生することがあります。\
誤差が発生する原因は、i-Reporterが内部で二進数計算をしているためです。

Excelでも計算中に誤差が発生しますが、計算結果は補正されています。

この補正アルゴリズムの条件が複雑であるため、i-ReporterとExcelとで小数計算結果を完全一致させることができません。

{% hint style="info" %}
【参考：Microsoft Learn】 ※外部サイト

[浮動小数点演算が Excel で不正確な結果をもたらす可能性がある](https://docs.microsoft.com/ja-jp/office/troubleshoot/excel/floating-point-arithmetic-inaccurate-result)
{% endhint %}

{% hint style="success" %}
【例】Excelでの計算誤差

* 3/10 ー　2/10 ー　1/10　= 0
* (3/10 ー　2/10 ー　1/10) = -2.77556E-17  ※-0.0000000000000000277556

このように、括弧の有無で誤差の補正が変化します。\
i-Reporterでの計算結果は、上記２つとも"0"となります。
{% endhint %}

## **回避方法**

Excelとの誤差は、ROUND関数を利用して四捨五入することで回避可能です。

{% hint style="success" %}
【例】

* **Excelの場合**\
  1/3＋1/3+1/3=1
* **i-Reporterの場合**\
  1/3＋1/3+1/3=0.9999999999…

「1/3＋1/3+1/3の計算結果をIF関数で”1”と判定させたい」場合、

IF(1/3＋1/3+1/3 = 1, “OK”,”NG”)\
＝”NG”となる（Excelは”OK”）

↓

IF(ROUND(1/3＋1/3+1/3, 5) = 1, “OK”,”NG”)\
＝”OK”となる
{% endhint %}


---

# 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://manuals.i-reporter.jp/create-a-form/prepare-the-formexcelfile/excelfunctions/excelfunctionroundingerror-and-workaround.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.
