Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - machine dependent left shift results

 
Thread Tools Search this Thread
Old 10-01-2009, 04:39 AM   #1
Default machine dependent left shift results


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
  Reply With Quote
Old 10-01-2009, 09:23 PM   #2
easily_confused
 
Posts: n/a
Default Re: machine dependent left shift results
reposted on comp.lang.perl.misc
please respond there


"easily_confused" <> wrote in message
news:003ff6be$0$32523$...
> 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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
java applet and accesing results from a database Ayesha General Help Related Topics 0 08-12-2009 04:15 PM
pcAnywhere and Brother fax machine on same phoen line bem522 Software 0 07-20-2007 04:20 PM
Evidence Mounts That The Vote Was Hacked Jas DVD Video 272 12-27-2004 09:22 PM
"The biggest scandal to ever hit American politics" Jas DVD Video 149 12-05-2004 02:47 PM
Re: Can't login to XP Pro machine Gary A+ Certification 3 09-22-2004 10:17 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46