0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

丸めアルゴリズムおぼえがき

Last updated at Posted at 2015-05-13

IEEE 754-2008標準では5種類の丸めアルゴリズムが定義されている。うち2種類は最近接な値に丸める方法であり、残り3種類は方向丸めと呼ぶ。

★最近接丸め(偶数)
Pattern0:CType((3.45D * 10), Integer) / 10
3.4
Pattern1:Math.Round(3.45D, 1)
3.4
Pattern2:Math.Round(3.45D, 1, MidpointRounding.ToEven)'銀行丸め・偶数丸め・IEEE754-4
3.4

★最近接丸め(0から遠いほうへ)//日本の義務教育で習う四捨五入はこれ
Pattern3:Math.Round(3.45D, 1, MidpointRounding.AwayFromZero)'対称算術型丸め
3.5

0方向への丸め

正の無限大への丸め

負の無限大への丸め

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?