Issue #8401 has been reported by akr (Akira T.).
Bug #8401: BigDecimal.new(“2”).power(1e20) is zero.
Author: akr (Akira T.)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.1.0dev (2013-05-13 trunk 40697) [x86_64-linux]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN
ふと見つけたのですが、BigDecimal.new(“2”).power(1e20) が 0.0 になります。
% ./ruby -v -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e20)’
ruby 2.1.0dev (2013-05-13 trunk 40697) [x86_64-linux]
0.0
以下のように、power の引数が
1e1 や 1e2 なら値が出てきて、
1e10 ならエラーになるのに、
1e20 になるとまたエラーじゃなくなって 0.0 になっちゃうのは
変ではないでしょうか。
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e1)’
0.1024E4
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e2)’
0.1267650600228229401496703205376E31
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e10)’
-e:1:in power': integer 10000000000 too big to convert to
int’
(RangeError)
from -e:1:in `’
Issue #8401 has been updated by mrkn (Kenta M.).
Category set to ext
Assignee set to mrkn (Kenta M.)
1.9.3p392 では -Infinity になるから、2.0.0p0 で導入されたバグですねぇ。
Bug #8401: BigDecimal.new(“2”).power(1e20) is zero.
Author: akr (Akira T.)
Status: Open
Priority: Normal
Assignee: mrkn (Kenta M.)
Category: ext
Target version:
ruby -v: ruby 2.1.0dev (2013-05-13 trunk 40697) [x86_64-linux]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN
ふと見つけたのですが、BigDecimal.new(“2”).power(1e20) が 0.0 になります。
% ./ruby -v -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e20)’
ruby 2.1.0dev (2013-05-13 trunk 40697) [x86_64-linux]
0.0
以下のように、power の引数が
1e1 や 1e2 なら値が出てきて、
1e10 ならエラーになるのに、
1e20 になるとまたエラーじゃなくなって 0.0 になっちゃうのは
変ではないでしょうか。
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e1)’
0.1024E4
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e2)’
0.1267650600228229401496703205376E31
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e10)’
-e:1:in power': integer 10000000000 too big to convert to
int’
(RangeError)
from -e:1:in `’
2013/5/14 mrkn (Kenta M.) [email protected]:
1.9.3p392 $B$G$O(B -Infinity $B$K$J$k$+$i!"(B2.0.0p0
$B$GF3F~$5$l$?%P%0$G$9$M$'!#(B
$B$3$C$A$N(B Debian GNU/Linux $B$G$O(B 1.9.3p392 $B$G$b(B 0.0
$B$G$9$M$'!#(B
$B$=$A$i$N4D6-$O=q$$$F$"$j$^$;$s$,!"4D6-0MB8$G$7$g$&$+!#(B
% ruby-1.9.3p392 -v -rbigdecimal -e ‘puts
BigDecimal.new(“2”).power(1e20)’
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
0.0
$B$“$H!”(B2**(1e20) $B$,Ii$K$J$k$N$O$*$+$7$$$H;W$&$N$G!"(B-Infinity
$B$O$=$l$O$=$l$G(B
$BJQ$@$H;W$$$^$9!#(B
Issue #8401 has been updated by mrkn (Kenta M.).
Status changed from Open to Closed
It is corrected in 1.2.3.
$ ruby -ve ‘gem “bigdecimal”, “1.2.3”; require “bigdecimal”; puts
BigDecimal(2).power(1e20)’
ruby 1.9.3p484 (2013-11-22) [x86_64-darwin12.5.0]
Infinity
$ ruby -ve ‘gem “bigdecimal”, “1.2.3”; require “bigdecimal”; puts
BigDecimal(2).power(1e20)’
ruby 2.0.0p353 (2013-11-22) [x86_64-darwin12.5.0]
Infinity
Bug #8401: BigDecimal.new(“2”).power(1e20) is zero.
Author: akr (Akira T.)
Status: Closed
Priority: Normal
Assignee: mrkn (Kenta M.)
Category: ext
Target version:
ruby -v: ruby 2.1.0dev (2013-05-13 trunk 40697) [x86_64-linux]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN
ふと見つけたのですが、BigDecimal.new(“2”).power(1e20) が 0.0 になります。
% ./ruby -v -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e20)’
ruby 2.1.0dev (2013-05-13 trunk 40697) [x86_64-linux]
0.0
以下のように、power の引数が
1e1 や 1e2 なら値が出てきて、
1e10 ならエラーになるのに、
1e20 になるとまたエラーじゃなくなって 0.0 になっちゃうのは
変ではないでしょうか。
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e1)’
0.1024E4
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e2)’
0.1267650600228229401496703205376E31
% ./ruby -rbigdecimal -e ‘puts BigDecimal.new(“2”).power(1e10)’
-e:1:in power': integer 10000000000 too big to convert to
int’
(RangeError)
from -e:1:in `’