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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:59:45+00:00 2026-06-16T02:59:45+00:00

I have 2 chars: HIGH and LOW and I’d like to convert them to

  • 0

I have 2 chars: HIGH and LOW and I’d like to convert them to an int corresponding to HIGH + the 2 left bits from LOW.

I tried somethine like :

unsigned char high;
unsigned char low;
high = 128; // 10000000
low= 128; // 10000000
int result; (should be high 10000000 + 2 left bites of low 10 = 1000000010)
// To do
return result;

Edited for more clarity.

The solution I chosed is:

return high*4 + (low >> (CHAR_BIT - 2));
  • 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-16T02:59:47+00:00Added an answer on June 16, 2026 at 2:59 am

    You declare HIGH and LOW as char*, but you don’t use them as pointer. The following code works fine (BTW, avoid upper case identifiers when you don’t use constants):

    char high = 125;
    char low = 12;
    

    This is how I understand your question (it could be more understandable):

    #include <limits.h>
    
    int result = high + (low >> (CHAR_BIT - 2));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this qsort: void qsort(void *a[],int low,int high, int (*compare)(void*,void*)); When I
Have an array of chars like char members[255]. How can I empty it completely
I have a UILabel that displays some chars. Like x, y or rpm. How
I have a table IntradayPrices1Minute where I store 1 minute timeframe open, high, low
I have an Arduino and I am wondering exactly what HIGH and LOW mean,
I have a high-priority process that needs to pass data to a low-priority process.
I'm trying to retrieve data for a Open-high-low-close (OHLC) chart directly from the database,
I have the following code: $.ajax({ async: false, url: 'chart_data.php', data: {'option':'high', 'id':id}, dataType:
I have 145064642 chars long HTML String which I am trying to print. When
I have non-ascii chars in velocity template files. And when processed they are garbled.

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.