[#47409] [ruby-trunk - Feature #6973][Open] Add an #integral? method to Numeric to test for whole-number values — "regularfry (Alex Young)" <alex@...>

12 messages 2012/09/03

[#47481] [ruby-trunk - Bug #7008][Open] rake is crashing when trying to compile ffi gem — "drookie (Eugene M. Zheganin Eugene M. Zheganin)" <eugene@...>

10 messages 2012/09/12

[#47505] [ruby-trunk - Feature #7019][Open] allow `private` and `protected` keywords to take blocks — "alexeymuranov (Alexey Muranov)" <redmine@...>

15 messages 2012/09/13

[#47582] [ruby-trunk - Bug #7037][Open] float formatting inconsistently rounds half to even — "headius (Charles Nutter)" <headius@...>

14 messages 2012/09/19

[#47638] [ruby-trunk - Bug #7046][Open] ERB#run and ERB#result are not safe for concurrent use — "headius (Charles Nutter)" <headius@...>

11 messages 2012/09/21

[#47655] [ruby-trunk - Feature #7051][Open] Extend caller_locations API to include klass and bindings. Allow caller_locations as a method hanging off Thread. — "sam.saffron (Sam Saffron)" <sam.saffron@...>

13 messages 2012/09/23

[#47657] [ruby-trunk - Feature #7055][Open] Allow `.foo=` as a synonym of `self.foo=` — "alexeymuranov (Alexey Muranov)" <redmine@...>

11 messages 2012/09/23

[#47730] [ruby-trunk - Bug #7085][Open] Subversion → GitHub gateway stops. — "shyouhei (Shyouhei Urabe)" <shyouhei@...>

27 messages 2012/09/29

[#47735] [ruby-trunk - Bug #7087][Open] ::ConditionVariable#wait does not work with Monitor because Monitor#sleep does not exist — "rklemme (Robert Klemme)" <shortcutter@...>

10 messages 2012/09/29

[#47759] [ruby-trunk - Bug #7092][Open] StringScanner start-of-line matches false positives, while lookbehind for a newline gives false negatives — "jayferd (Jay Adkisson)" <jjmadkisson@...>

8 messages 2012/09/30

[ruby-core:47448] [ruby-trunk - Bug #6986] Inconsistent result of BigDecimal#power

From: "phasis68 (Heesob Park)" <phasis@...>
Date: 2012-09-06 09:19:37 UTC
List: ruby-core #47448
Issue #6986 has been updated by phasis68 (Heesob Park).


Could you try "p BigDecimal('1e-10').power(1e50)" ?
On Windows, the parameter higher than 1e19 returns Infinity instead of 0.0.


Here is a patch of NoMemoryError on Windows.

diff --git a/bigdecimal.c b/bigdecimal.c.new
index e798781..976503b 100644
--- a/bigdecimal.c
+++ b/bigdecimal.c.new
@@ -2184,7 +2184,7 @@ retry:
     if (exp != NULL) {
        return rmpd_power_by_big_decimal(x, exp, n);
     }
-    else if (TYPE(vexp) == T_BIGNUM) {
+    else if (TYPE(vexp) == T_BIGNUM || FIX2INT(vexp)>=10000000) {
        VALUE abs_value = BigDecimal_abs(self);
        if (is_one(abs_value)) {
            return ToValue(VpCreateRbObject(n, "1"));

----------------------------------------
Bug #6986: Inconsistent result of BigDecimal#power
https://bugs.ruby-lang.org/issues/6986#change-29206

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 
ruby -v: ruby 2.0.0dev (2012-09-05 trunk 36913) [i386-mswin32_100]


I found BigDecimal#power returns incorrect result for a large value.

C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e7)"
#<BigDecimal:a2bdb8,'0.1E-99999999',9(100000026)>

C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e8)"
-e:1:in `power': failed to allocate memory (NoMemoryError)
        from -e:1:in `<main>'
	
C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e10)"
#<BigDecimal:f7cb3c,'0.0',9(18)>

C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e19)"
#<BigDecimal:f7cb3c,'Infinity',9(18)>




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

In This Thread