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

  • Home
  • SEARCH
  • 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 9016497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:00:44+00:00 2026-06-16T04:00:44+00:00

Variable intVar is primitive int, bb[] is byte array {0x02,0xF7,0x8B,0xF9}; intVar = bb[0]; //intVar

  • 0

Variable intVar is primitive int, bb[] is byte array {0x02,0xF7,0x8B,0xF9};

  intVar = bb[0];
  //intVar = 00000002    
  intVar <<= 8;
  //intVar = 00000200
  intVar |= bb[1];
  //intvar = fffffff7

Why????

  • 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-16T04:00:45+00:00Added an answer on June 16, 2026 at 4:00 am

    The reason is sign extension. Use:

      intVar = 0xFF & bb[0];
      //intVar = 00000002    
      intVar <<= 8;
      //intVar = 00000200
      intVar |= 0xFF & bb[1];
      // intVar = 000002F7
    

    Using a negative byte (java bytes are signed) as int results in a negative int, and because java uses two’s complement all leading bits will be 1. Anding that with 0xFF will get you the byte you had in the lowest 8 bits and 24 leading 0s.

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

Sidebar

Related Questions

Variable outside of the loop int number = 0; for(int i = 0; i
How long does it take to declare a variable in C, for example int
Possible Duplicate: Is array name a pointer in C? I passed in an int
So if I have a recursive function with a global variable var_: int var_;
I have class like this class variable { public: variable(int _type=0) : type(_type), value(NULL),
Variable names in haskell need to be in small case, but How to declare
the variable doc is not accessible anywhere else in the method outside of the
The variable filepath which is a string contains the value Música . I have
The variable cherrypy.request.params as it is described in the API contains the query string
num is a variable which is dynamically changed within 1 to 9. I must

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.