On 11/3/05, JeeBee <[EMAIL PROTECTED]> wrote: > > Thank you, John! > I see the limit is 32 bits now. > I just added 'use bigint', how easy! > > Further, I was wondering about why you said I wasn't just multiplying by > 2 using $p<<=1. Isn't it exactly equal to $p*=2 ???
It is equal just up to the moment the result goes over the maximum integer value. This is a build-dependent parameter, being 2**32 - 1 or 2**64 - 1, according to the Config value ivsize. perl -V:ivsize That is, the maximum integer is something like 2**(ivsize*8) - 1. The shift is an integer-type operation and will produce the same weird results you see in programming C with an integer of the same type. For example, in a perl which uses 64-bit integers: $ perl -e 'print 1<<63, " ", 1<<64' 9223372036854775808 1 But the multiplication operator (*) is smarter and does an upgrade from integer to floating point when needed, (possibly) increasing the range of the correct results. Adriano. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>