Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8035313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:16:35+00:00 2026-06-05T02:16:35+00:00

How do I convert the below piece of java code to C++. I know

  • 0

How do I convert the below piece of java code to C++. I know I can write
typedef unsigned char byte so that is taken care of, but I don’t understand what the |= and <<= are meant for. And how does one replace final

public static final long unsignedIntToLong(byte[] b) {
          long l = 0;
          l |= b[0] & 0xFF;
          l <<= 8;
          (l >>> 4) & 0x0F;

How do I test all this in C++ – are there some unit tests I can run as I go about the conversion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:16:38+00:00Added an answer on June 5, 2026 at 2:16 am

    First thing, |= is a compound bitwise OR assignment. a |= b is equivalent to a = a | b, where each resulting bit will be set if either that bit in a or b is set (or both).

    Here’s a truth table that is applied to each bit:

    a | b | result
    --------------
    0 | 0 | 0
    0 | 1 | 1
    1 | 0 | 1
    1 | 1 | 1
    

    Secondly, <<= is the same, but instead of a bitwise or, it’s a bit shift to the left. ALl existing bits are moved left by that amount, and the right is padded with 0s.

    101 << 1 == 1010
    110 << 2 == 11000
    

    final is the same as C++’s const by the variable definition. If, however, you want to prevent a function from being overriden, you may tag final onto the end of the function header if the function is also a virtual function (which it would need to be in order to be overriden in the first place). This only applies to C++11, though. Here’s an example of what I mean.

    Finally, >>> is called the unsigned right shift operator in Java. Normally, >> will shift the bits, but leave the leftmost bit intact as to preserve the sign of the number. Sometimes that might not be what you want. >>> will put a 0 there all the time, instead of assuming that the sign is important.

    In C++, however, signed is an actuality that is part of the variable’s type. If a variable is signed, >> will shift right as Java does, but if the variable is unsigned, it will act like the unsigned right shift (>>>) operator in Java. Hence, C++ has only the need for >>, as it can deduce which to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code where I'm trying to convert the below C#
Can someone convert below code to ASP format? <?php $data = ' [ {
How can I convert below code in LINQ foreach (RepeaterItem ri in rptNews.Items) {
How can I convert below code to vb.net? I can not convert select new
The following code works perfectly. My only concern is that I wanna convert below
Can any one help me convert the below code to LINQ? Select Catg,Count(*) From
How do I convert the below PHP code to VB.NET? <?php $X_HOST =foo.com; $X_URL
I'm trying to convert the below bit of code into VB (and obviously apply
I'm struggling to convert the below code to C#. Class Class1 Implements IMyInterface Public
Any help would be appreciated, I'm trying to convert the code below to C#,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.