machine dependent left shift results

  • Thread starter easily_confused
  • Start date
E

easily_confused

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top