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 8998603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:03:34+00:00 2026-06-16T00:03:34+00:00

I got to ask How to Set upper and lower bytes of an (short

  • 0

I got to ask How to Set upper and lower bytes of an (short int) in C++ .

we use this for get upper and lower but now how to set upper and lower bytes of a short int.

int number = 3510;

char upper = number >> 8;

char lower = number && 8;

thanks 🙂

after reading your answer i found a problem look my code please :

int number = 55;
int mynumber = 0;

char upper = number >> 8;

char lower = number && 8;

mynumber = (mynumber & 0xff00) | lower;
mynumber = (mynumber & 0x00ff) | (upper << 8);

printf("%i",mynumber);

it just return 1 but must return 55 !
how to fix it?

  • 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-16T00:03:35+00:00Added an answer on June 16, 2026 at 12:03 am

    To set upper byte:

    number = (number & 0x00ff) | (upper << 8);
    

    To set lower byte:

    number = (number & 0xff00) | lower;
    

    Both upper and lower should be char or unsigned char type.

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

Sidebar

Related Questions

got a problem, can't get my head around this jquery and would appreciate your
I'm a little embarrassed to ask this as I ought to know better, but
I'm sure this is a very noob thing to ask but I can't seem
I would like to ask this question, because I'm not sure if I got
I've got a function that uses readline to ask people to enter in data.
I want to ask about strcpy. I got problem here. Here is my code:
I've found myself in a situation, that makes me ask for help. I've got
Got this error message while trying to load view: The model item passed into
Got a question for some jQuery wizard who might stumble upon this. When I
This is how one can set them up: http://www.c-sharpcorner.com/uploadfile/rmcochran/commandpromptinstudiotoolsmenu01152008103357am/commandpromptinstudiotoolsmenu.aspx My problem is that I

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.