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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:07:31+00:00 2026-06-17T19:07:31+00:00

I struggle masking a uint64_t variable by N bytes. I do not know N

  • 0

I struggle masking a uint64_t variable by N bytes. I do not know N but I know it is 8 or less. My current code looks like this:

// uint64_t n is given
uint64_t mask;
for( mask = 0x00; n; n--) {
    mask = mask<<8 | 0xFF;
}

for building the mask. What am I doing wrong here?

Edit:
The question was answered. Anyway, for better understanding:

I want a mask like this:

0x000000FF // or:
0x0000FFFF // or:
0x00FFFFFF

to take 1, 2 or more byte from the data. As the comments say, my code works! Maybe I had an bug anywere else!

  • 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-17T19:07:33+00:00Added an answer on June 17, 2026 at 7:07 pm

    It should work, according to the [operator precendence table1].

    Still, it’s more clear to write it as:

    mask <<= 8;
    mask |= 0xff;
    

    or:

    mask = (mask << 8) | 0xff;
    

    You can also do it with a look-up table, of course.

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

Sidebar

Related Questions

I'm struggle extracting necessary data from this json stored inside php variable. Not yet
struggle extracting necessary data from this complex json stored inside php variable. Via php
I struggle with dates and times in R, but I am hoping this is
Now I know there are quite a few questions regarding this but in general
I know there are multiple variations of this scenario but I've struggled making it
We all know you can't do things like this: int a = 7; new
I had a bit of a struggle trying to understand why my code was
I continue to struggle with array! This is probably easy to answer. I'm retrieving
Last two nights I am struggle with below code. The problem is I need
I struggle with some caching issue inside Django. So far I've seen this issue

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.