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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:10:42+00:00 2026-06-12T02:10:42+00:00

unsigned char Mid; if( (data[2]) == 0x9A){ Mid = data[5]; if( (Mid == 1)

  • 0
    unsigned char Mid;

if( (data[2]) == 0x9A){
    Mid = data[5];

    if( (Mid == 1) || (Mid == 2) || (Mid == 3) )
        return(Mid);

The code above gives:

warning: comparison is always false due to limited range of data type

error as I expected.

It’s ok if I type

if( (unsigned char)data[2] == 0x9A){

or

if( (data[2]&0xFF) == 0x9A){

I understand the first one, but what happens in the second one?

What is the effect of masking with 0xFF?

  • 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-12T02:10:44+00:00Added an answer on June 12, 2026 at 2:10 am
    • When casting the value to unsigned char, you are doing an explicit type conversion.

    • When you mask the value with 0xFF, an implicit type conversion takes place.

    You have the signed char data[2] and 0xFF as operands to the bitwise AND operator. Because one of the operands (0xFF) cannot fit inside a signed char, both operands are implicitly converted into an unsigned type.

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

Sidebar

Related Questions

unsigned char* Data::getAddress(unsigned char* address) { strcpy((char*)address, (char*)this->_address); return (unsigned char*)address; } int main()
I have the following code int ParseData(unsigned char *packet, int len) { struct ethhdr
My code below gave a different length for the unsigned char pointer I expect.
I came across the below lines in code unsigned char A = 0xB9; unsigned
Suppose this code: unsigned char list[3] = { 1, 2, 3 }; struct _struct{
c++: static void doIp(byte data[]) { unsigned char j, k; byte val; byte buf[8];
If I have these code: unsigned char **keys; int *num_keys; int num_images = (int)
char *pStrBuffer; unsigned char data; unsigned int Address; /* pStrBuffer reading from a file
void callback(const unsigned char* data, int len) { unsigned char copydatahere; } data is
each source file has a function: unsigned char test(){ //return true if tests succceed

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.