in reply to Left shift operation done more than 32 times

I ran this out of interest on the Perl that comes with Solaris 10 SPARC edition, output from perl -V below

Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Platform: osname=solaris, osvers=2.10, archname=sun4-solaris-64int uname='sunos localhost 5.10 sun4u sparc SUNW,Ultra-2' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xar +ch=v8 -D_TS_ERRNO', optimize='-xO3 -xspace -xildoff', cppflags='' ccversion='Sun WorkShop', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=87654321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='of +f_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags ='' libpth=/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R /usr/ +perl5/5.8.4/lib/sun4-solaris-64int/CORE' cccdlflags='-KPIC', lddlflags='-G' Characteristics of this binary (from libperl): Compile-time options: USE_64_BIT_INT USE_LARGE_FILES Locally applied patches: 22667 The optree builder was looping when constructing the ops ... 22715 Upgrade to FileCache 1.04 22733 Missing copyright in the README. 22746 fix a coredump caused by rv2gv not fully converting a PV ... 22755 Fix 29149 - another UTF8 cache bug hit by substr. 22774 [perl #28938] split could leave an array without ... 22775 [perl #29127] scalar delete of empty slice returned garbage 22776 [perl #28986] perl -e "open m" crashes Perl 22777 add test for change #22776 ("open m" crashes Perl) 22778 add test for change #22746 ([perl #29102] Crash on assign ... 22781 [perl #29340] Bizarre copy of ARRAY make sure a pad op's ... 22796 [perl #29346] Double warning for int(undef) and abs(undef) ... 22818 BOM-marked and (BOMless) UTF-16 scripts not working 22823 [perl #29581] glob() misses a lot of matches 22827 Smoke [5.9.2] 22818 FAIL(F) MSWin32 WinXP/.Net SP1 (x86/1 cpu) 22830 [perl #29637] Thread creation time is hypersensitive 22831 improve hashing algorithm for ptr tables in perl_clone: ... 22839 [perl #29790] Optimization busted: '@a = "b", sort @a' ... 22850 [PATCH] 'perl -v' fails if local_patches contains code snippets 22852 TEST needs to ignore SCM files 22886 Pod::Find should ignore SCM files and dirs 22888 Remove redundant %SIG assignments from FileCache 23006 [perl #30509] use encoding and "eq" cause memory leak 23074 Segfault using HTML::Entities 23106 Numeric comparison operators mustn't compare addresses o +f ... 23320 [perl #30066] Memory leak in nested shared data structur +es ... 23321 [perl #31459] Bug in read() SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962 Built under solaris Compiled at Feb 13 2006 05:12:02 @INC: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .

Running with a limit of 129 produces the following

0: 1 1: 2 2: 4 3: 8 4: 16 5: 32 6: 64 7: 128 8: 256 9: 512 10: 1024 11: 2048 12: 4096 13: 8192 14: 16384 15: 32768 16: 65536 17: 131072 18: 262144 19: 524288 20: 1048576 21: 2097152 22: 4194304 23: 8388608 24: 16777216 25: 33554432 26: 67108864 27: 134217728 28: 268435456 29: 536870912 30: 1073741824 31: 2147483648 32: 4294967296 33: 8589934592 34: 17179869184 35: 34359738368 36: 68719476736 37: 137438953472 38: 274877906944 39: 549755813888 40: 1099511627776 41: 2199023255552 42: 4398046511104 43: 8796093022208 44: 17592186044416 45: 35184372088832 46: 70368744177664 47: 140737488355328 48: 281474976710656 49: 562949953421312 50: 1125899906842624 51: 2251799813685248 52: 4503599627370496 53: 9007199254740992 54: 18014398509481984 55: 36028797018963968 56: 72057594037927936 57: 144115188075855872 58: 288230376151711744 59: 576460752303423488 60: 1152921504606846976 61: 2305843009213693952 62: 4611686018427387904 63: 9223372036854775808 64: 4294967296 65: 8589934592 66: 17179869184 67: 34359738368 68: 68719476736 69: 137438953472 70: 274877906944 71: 549755813888 72: 1099511627776 73: 2199023255552 74: 4398046511104 75: 8796093022208 76: 17592186044416 77: 35184372088832 78: 70368744177664 79: 140737488355328 80: 281474976710656 81: 562949953421312 82: 1125899906842624 83: 2251799813685248 84: 4503599627370496 85: 9007199254740992 86: 18014398509481984 87: 36028797018963968 88: 72057594037927936 89: 144115188075855872 90: 288230376151711744 91: 576460752303423488 92: 1152921504606846976 93: 2305843009213693952 94: 4611686018427387904 95: 9223372036854775808 96: 4294967296 97: 8589934592 98: 17179869184 99: 34359738368 100: 68719476736 101: 137438953472 102: 274877906944 103: 549755813888 104: 1099511627776 105: 2199023255552 106: 4398046511104 107: 8796093022208 108: 17592186044416 109: 35184372088832 110: 70368744177664 111: 140737488355328 112: 281474976710656 113: 562949953421312 114: 1125899906842624 115: 2251799813685248 116: 4503599627370496 117: 9007199254740992 118: 18014398509481984 119: 36028797018963968 120: 72057594037927936 121: 144115188075855872 122: 288230376151711744 123: 576460752303423488 124: 1152921504606846976 125: 2305843009213693952 126: 4611686018427387904 127: 9223372036854775808 128: 4294967296 129: 8589934592

Once we get beyond 63 shifts, the behaviour seems to be to cycle around the high order 32 bits. The behaviour may well be different for a Perl built with GCC rather than Sun's own compiler or with Solaris 10 on the Intel/AMD 64-bit architecture.

Cheers,

JohnGG