Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Difference between Perl and Java for << operator?

by BillKSmith (Monsignor)
on Jul 30, 2021 at 17:58 UTC ( [id://11135535]=note: print w/replies, xml ) Need Help??


in reply to Difference between Perl and Java for << operator?

The answer to your question is hidden in the documentation for Integer Arithmetic. You need use integer; if you want your result as a signed integer. (By default it is treated as an unsigned integer.) Note also, that your << 28 assumes that your perl is compiled for 32-bit integers.
Bill

Replies are listed 'Best First'.
Re^2: Difference between Perl and Java for << operator?
by syphilis (Archbishop) on Jul 31, 2021 at 10:25 UTC
    Note also, that your << 28 assumes that your perl is compiled for 32-bit integers

    Well spotted - if you want to use the perl sub that the OP provided then:
    1) you will need to be running under the use integer pragma;
    and
    2) you will also need to be running a perl that was built with 32-bit integers.

    However, as has also been demonstrated, there are ways to obtain the desired result by doing a 0xFFFFFFFF << 28, that will work on both 32-bit integer and 64-bit integer builds.

    Cheers,
    Rob
Re^2: Difference between Perl and Java for << operator?
by eyepopslikeamosquito (Archbishop) on Jul 31, 2021 at 07:33 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-03-29 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found