[#37021] [RAA] RAA/2.3 — "U.Nakamura" <usa@...>

みなさんこんにちは。

20 messages 2003/01/30

[ruby-list:36917] Re: Numeric#bankers_round

From: Take_tk <ggb03124@...>
Date: 2003-01-08 08:31:10 UTC
List: ruby-list #36917
たけ(tk)です


[ruby-list:36914] Re: Numeric#bankers_round にて
matz@ruby-lang.org (Yukihiro Matsumoto) さん曰く:

> 「いわゆるbankers_round」というのをそもそも知らなかったので
> すが、ゼロから遠い方に丸めるというのがCのround(3)の仕様で、
> Rubyもそれを踏襲してます。Cだとrint(3)が偶数に丸めるみたい。

 某言語(^^;以外ではPHPというかPythonとVBがバンカーズラウンドを使ってい
るらしい。IEEE 754 のデフォルトの丸めモードだそうです。

----

http://php.ilisys.com.au/manual/en/printwn/function.round.php
PHP uses Bankers rounding.
2.45000 is rounded to 2.4
2.45001 is rounded to 2.5

 ↓はPython
http://fixedpoint.sourceforge.net/html/lib/fixedpoint-rounding.html
By default, FixedPoint objects use a type of rounding typically referred
to as "Banker's Rounding" which is useful in financial applications. 

 ↓はVB。
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemmathclassroundtopic4.asp
The behavior of this method follows IEEE Standard 754, section 4. This
kind of rounding is sometimes called rounding to nearest, or banker's
rounding. If digits is zero, this kind of rounding is sometimes called
rounding toward zero.

 ↓はJavaでの説明だが、Javaでは採用しなかったと書いてある。
http://www.y-adagio.com/public/standards/tr_javalang/4.doc.htm
二つの同程度 に近い代表値があるときは,もっとも重みのないビット(Least
Significant Bit,LSB)がゼロのものが選ばれる。これが, 直近への丸め
(round to nearest) として知られている,IEEE 754規格のデフォルト丸めモー
ドである。

 これは何の説明なのだろうか?
http://research.compaq.com/SRC/m3sources/html/float/src/IEEE-default/FloatMode.i3.html
TYPE RoundingMode =
  {NearestElseEven, TowardMinusInfinity, TowardPlusInfinity,
   TowardZero, NearestElseAwayFromZero, IBM370, Other};
Rounding modes. The first four are the IEEE modes.
CONST RoundDefault = RoundingMode.NearestElseEven;

Take_tk = KUMAGAI Hidetake
たけ(tk)=熊谷秀武


In This Thread