Project

General

Profile

Actions

Bug #5713

closed

Fixnum#** returns Infinity for 0 ** negative Bignum

Added by john_firebaugh (John Firebaugh) about 13 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
Backport:
[ruby-core:41494]

Description

=begin
Instead it should raise ZeroDivisionError, the same as negative Fixnums.

wordsize = 8 * 1.size
fixnum_min = -2 ** (wordsize - 2)

def zero_power(exp)
0 ** exp
rescue ZeroDivisionError
"ZeroDivisionError"
end

[-1, fixnum_min, (fixnum_min-1)].each {|i| puts zero_power(i)}
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #5715: +/-1 ** Bignum returns different results than +/-1 ** FixnumClosedmarcandre (Marc-Andre Lafortune)12/06/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0