From: Mark Hubbart Date: 2005-05-05T02:06:07+09:00 Subject: Re: Fixnum's binary representation On 5/4/05, camsight@gmail.com wrote: > Thanks, Robert! > > > For which numbers do you have problems? I don't see any so far > > I mean... > If Bignum#[] is made to simulate 32-bit signed integers, it can't show > numbers with more than 32-bit representation. > Well, positive numbers will be okay. > But what about negative numbers? > When can I expect the sign bit? > I assume that numbers beyond 32-bit are not suitable for Bignum#[]. > Do you agree? IIUC, it's not precisely a "sign bit"; it's more like an entire bit-flip. -1 is zero, bit-flipped. So if you are trying to use Integer#[] to get determine the sign of a number, the question is simply: how high do you want to go? integer[512] will correctly determine sign for numbers in the range of (-(2**512-1)..2**512) (that is, a 512 bit integer). There no way (that I can think of) to use Integer#[] to return the correct sign on *any* integer usable in Ruby. hth, Mark