machine dependent left shift results

Discussion in 'Perl' started by easily_confused, Oct 1, 2009.

  1. On a 32 bit machine, ~0<<32 gives 11111111111111111111111111111111 (I was
    expecting 0)

    (~0<<31)<<1 gives 0.

    I was trying ~(~0<<$size) to create a mask of $size ones.

    ((1<<$size) -1) was what I tried first but it also failed for the same
    reason, I guess.

    I like that in verilog I can just say {$size{1'b1}}

    I know I can use Math::BigInt, but I still wonder what the rationale is
    behind the first example failing.

    EC
     
    easily_confused, Oct 1, 2009
    #1
    1. Advertisements

  2. reposted on comp.lang.perl.misc
    please respond there
     
    easily_confused, Oct 1, 2009
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.