みたいなのが挙げられます。これが話題になった時にSNSで見かける言説が「十進小数 (decimal) 型ならこういう問題はない」です。 ですが、decimal型は十進小数を正確に表現できるという話でしかなく、全ての実数を正確に表現できるわけではありません。例えば、 1.0 / 3.0 * 3.0 の計算を考えてみましょう。数学的には、これはちょうど 1.0 になるはずです。 C#の場合 C#には標準の decimal 型があります。これで 1.0 / 3.0 * 3.0 を計算してみましょう。
decimal — Decimal fixed point and floating point arithmetic¶ Source code: Lib/decimal.py The decimal module provides support for fast correctly rounded decimal floating point arithmetic. It offers several advantages over the float datatype: Decimal “is based on a floating-point model which was designed with people in mind, and necessarily has a paramount guiding principle – computers must provide
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く