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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:53:29+00:00 2026-05-23T11:53:29+00:00

Recently I came across a line like this public final static int DELETION_MASK =

  • 0

Recently I came across a line like this

public final static int DELETION_MASK = 0x01;

why is it not like

public final static int DELETION_MASK = 1;

Is there any advantage in using the first approach other than 0xA and upper limit hexadecimals can be converted with ease?? In this case its just a constant representing 1.

  • 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-05-23T11:53:29+00:00Added an answer on May 23, 2026 at 11:53 am

    While there is not a difference in the code produced by the compiler, bit masks are traditionally written using the hexadecimal notation, because it’s significantly easier for a human to convert to a binary form. Another common convention is to include the leading zeros when the length of the field is known. E.g. for a C int field, it’s common to write:

    #define MASK 0x0000ffff
    

    In addition, hexadecimal constants indicate to the programmer that it’s probably a bit mask, or a value that will be somehow involved in bitwise operations and should probably be treated specially.

    As a bonus, hexadecimal notations may also avoid issues with negative numbers: 0xffffffff is in fact a negative number (-1 to be exact). Rather than juggling with the sign and 2’s-complement numbers you can just specify the mask in hexadecimal and be done with it.


    Since Java 7 you can also use binary literals which makes it even easier for a human to understand which bits are set in a bit mask. And binary literals may make use of underscores to put the bits into separate groups.

    That means that the following is also valid:

    public final static int DELETION_MASK = 0b0000_0001;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently came across this blog post which basically says that we should not
I recently came across some code that looks something like this: <head> <?php /*
I recently came across some code like this: parent && parent.removeChild(this); Which takes the
I recently came across this interview question (posted in a forum somehwere... looks like
I recently came across this line in a code - fprintf(logfile, |-IP Version :
I recently came across this line in a PHP script: $_REQUEST['start_date']=$date; Is it allowed
I recently came across a bit of not-well-tested legacy code for writing data that's
I recently came across a question about sequence points in C++ at this site,
I recently came across the following line of code: var type = (typeof x).toLowerCase();
I recently came across the pandas library for python, which according to this benchmark

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.