[ruby-dev:47844] Re: [ruby-changes:31994] mrkn:r44073 (trunk): * bigdecimal.c (BigDecimal_coerce): convert a Float to a BigDecimal instead
From:
Tanaka Akira <akr@...>
Date:
2013-12-08 12:54:11 UTC
List:
ruby-dev #47844
2013/12/8 mrkn <[email protected]>: > mrkn 2013-12-08 20:20:51 +0900 (Sun, 08 Dec 2013) > > New Revision: 44073 > > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44073 > > Log: > * bigdecimal.c (BigDecimal_coerce): convert a Float to a BigDecimal instead > of converting the receiver to a Float. > [ruby-core:58756] [Bug #9192] > > * test/bigdecimal/test_bigdecimal.rb: add tests for the above change. これを眺めて、推移律が成り立たないんじゃないかなぁ、と思ったので、 ちょっと試してみるとやはり反例を作れました。 % ./ruby -rbigdecimal -ve ' f1 = 131.2 f2 = 131.20000000000002 b = BigDecimal("131.2") p f1 == b p b == f2 p f1 == f2 ' ruby 2.1.0dev (2013-12-08 trunk 44077) [x86_64-linux] true true false このコミットで始まった話ではないようですが。 推移律が成り立たないというのは同値関係ではないということで、 気にする人はいるような気がします。 どのくらいの人が気にするかはわかりませんが。 -- [田中 哲][たなか あきら][Tanaka Akira]