> For the complete documentation index, see [llms.txt](https://manuals.i-reporter.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manuals.i-reporter.jp/create-a-form/prepare-the-formexcelfile/excelfunctions/excelfunctionroundingerror-and-workaround.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://manuals.i-reporter.jp/create-a-form/prepare-the-formexcelfile/excelfunctions/excelfunctionroundingerror-and-workaround.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
