From: Seebs Date: 2009-09-14T14:25:07+09:00 Subject: Re: Overflow behavior On 2009-09-13, Joel VanderWerf wrote: > jacob navia wrote: >> What is the official behavior of ruby in case of integer overflow? > > Integers overflow from Fixnums (30 bits) into Bignums (unlimited > precision integers). > > irb(main):003:0> x = 2**30 - 1 >=> 1073741823 > irb(main):004:0> x.class >=> Fixnum > irb(main):005:0> x+1 >=> 1073741824 > irb(main):006:0> (x+1).class >=> Bignum I looked briefly at the code underlying this. I am not totally convinced that it's impossible for a calculation (especially a multiplication) to evade the overflow detection used. -s -- Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!