Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: reproducing javascripts >> operator

by oiskuu (Hermit)
on Mar 20, 2015 at 19:26 UTC ( #1120794=note: print w/replies, xml ) Need Help??


in reply to reproducing javascripts >> operator

The (canonical) way to perform sign extension is via xor and subtract: sub sxtb { (shift ^ 0x80) - 0x80 }

For CRC digest, I'd consider using a specific module, but in a pinch, the following should work:

sub sxt { ((0xffffffff & shift) ^ 0x80000000) - 0x80000000 } ... $crc = ($crc >> 8) ^ ... $crc = sxt $crc; ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1120794]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2020-12-04 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (58 votes). Check out past polls.

    Notices?