Issue #7404 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to mrkn (Kenta Murata)
Target version set to 2.0.0


----------------------------------------
Bug #7404: BigDecimal#add(Float) ???? BigDecimal ???菴???????篁????????羲?膊???с???紊??????
https://bugs.ruby-lang.org/issues/7404#change-33806

Author: sho-h (Sho Hashimoto)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: 
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-19 trunk 37734) [x86_64-linux]


=begin
????????障?絲上?筝???篁??????????с????????#7176 ??絲上???????????BigDecimal#+ ??? Float ???羝<???????翫?????BigDecimal ???菴???c???????帥?????????с????????篁????????羲?膊????????篁ュ??????罕???? Float ???菴????????????с?????

箴??????違??BigDecimal#-???#sub ???箴???????障??????篁ヤ?????????????篏??????障?????(#+ ??? #add ?????????鴻?? BigDecimal ???菴??????障??)

  require "bigdecimal"
  a = BigDecimal.new("1.1")
  b = BigDecimal.new("2.2")
  c = 3.3

  p a - b # => #<BigDecimal:f9232478,'-0.11E1',18(36)>
  p a - c # => -2.1999999999999997
  p a.sub(b, 10) # => #<BigDecimal:f923239c,'-0.11E1',18(36)>
  p a.sub(c, 0)  # => -2.1999999999999997
  p a.sub(c, 10) # => ArgumentError

BigDecimal#sub ????茖???с????????BigDecimal_sub2 ??∽?違?篁ヤ??????????????c????????????????с????????c ??? Float ???篁e?ャ?????????????????GetVpValue ????????紊?????????с????????????????????障?????(膃? 2 綣???違?? 0 ??????絎?????????翫????? mx == 0 ???鴻?????????????????腟??????? Float ?????????????с??)

    if (mx == 0) return BigDecimal_sub(self, b);
    else {
       size_t pl = VpSetPrecLimit(0);
       VALUE   c = BigDecimal_sub(self,b); /* ????????с?? Float ??????吾?с??????菴???c?????? */
       VpSetPrecLimit(pl);
       GUARD_OBJ(cv,GetVpValue(c,1));      /* ????????? GetVpValueWithPrec ??? prec 綣???違?? -1 ???羝<????????箴?紊? */
       VpLeftRound(cv,VpGetRoundMode(),mx);
       return ToValue(cv);
    }

BigDecimal#add ?????????????????Rational ??? Float ???羝<??????????翫??????荐?膊?腟??????? BigDecimal ???????????????????????????????с????????????????障????????
=end



-- 
http://bugs.ruby-lang.org/