Forum: Ruby Crashing Fixnum#** with 64 bit Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel Berger (Guest)
on 2006-04-06 20:02
(Received via mailing list)
Hi all,

I thought this was interesting.  Should Ruby handle this better?  Or is
this a
case of, "Don't do that."?

# 32 bit Ruby, Solaris 10

irb(main):001:0> (2**32).class
=> Bignum
irb(main):002:0> (2**32) ** (2**33)
(irb):2: warning: in a**b, b may be too big
=> Infinity

## DANGER! DANGER! WILL BRING SYSTEM TO A CRAWL!

# 64 bit Ruby, Solaris 10

irb(main):002:0> (2**32).class
=> Fixnum
irb(main):003:0> (2**32) ** (2**33)
(irb):3:in `**': failed to allocate memory (NoMemoryError)
         from (irb):3:in `irb_binding'
         from /opt/test/lib/ruby/1.8/irb/workspace.rb:52:in
`irb_binding'
         from :0

The behavior is identical with or without Rational, btw.

Regards,

Dan
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-04-06 20:20
(Received via mailing list)
On Apr 6, 2006, at 2:01 PM, Daniel Berger wrote:

> (irb):2: warning: in a**b, b may be too big
>         from (irb):3:in `irb_binding'
>         from /opt/test/lib/ruby/1.8/irb/workspace.rb:52:in
> `irb_binding'
>         from :0
>
> The behavior is identical with or without Rational, btw.
>
> Regards,
>
> Dan
>

Incidently I get this:
% irb
irb(main):001:0> (2**32) ** (2**32)
/usr/local/ruby/lib/ruby/1.8/rational.rb:543: warning: in a**b, b may
be too big
=> Infinity
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-04-06 20:23
(Received via mailing list)
On Apr 6, 2006, at 2:01 PM, Daniel Berger wrote:
<snip>

You can ignore my previous message, I didn't fully read yours. D'Oh.
This topic is locked and can not be replied to.