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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:12:07+00:00 2026-05-15T13:12:07+00:00

I am writing a couple of functions that encode and decode a list of

  • 0

I am writing a couple of functions that encode and decode a list of options into a Long so they can easily be passed around the application, you know this kind of thing:

1 – Apple
2 – Orange
4 – Banana
8 – Plum
etc.

In this case the number 11 would represent Apple, Orange & Plum.

I’ve got it working but I see this used all the time so assume there is a common name for the technique, and no doubt all sorts of best practice and clever algorithms that are at the moment just out of my reach.

  • 1 1 Answer
  • 1 View
  • 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-15T13:12:07+00:00Added an answer on May 15, 2026 at 1:12 pm

    Bit Flags. It’s a technique used as part of Bitmasking.

    0001 – Apple
    0010 – Oranage
    0100 – Banana
    1000 – Plum

    Each 1 is the flagged bit.

    Now you can easily perform bitwise operations using those number:

    if((11 & Apple) == Apple) // The Apple Flag is set
    {
        // Do Something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am writing a magento product exporter, that writes a couple of attributes into
I'm writing a simple program that has a couple of functions that look like
I'm writing a web interface to MySQL that executes a couple queries and returns
I'm writing a small script that gathers a couple exif values from images... namely
I'm writing porting file-io set of functions from c into a c++ class. Magic
I'm googling around for a couple of days, and can't find clear method/lib for
I am writing a couple of django apps which by design are coupled together.
I've been writing Java for the last couple of years , and now I've
I am facing a couple of problems while writing an auto-memoizer in Scheme. I
I am writing a quickie BlackJack Winforms app to demonstrate a couple of concepts.

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.