From: Markus Roberts Date: 2009-09-15T03:37:45+09:00 Subject: Re: Overflow behavior Seebs -- I haven't looked at it in several years, but at one time I was pretty deep in that code and my recollection is that it's solid. Can you explain your misgivings in more detail (e.g. outline a hypothetical failure mode, even if you can't produce a concrete example)? -- MarkusQ On Sep 13, 2009, at 10:25 PM, Seebs wrote: > 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!