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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:02:49+00:00 2026-06-11T17:02:49+00:00

I am making an application in C# and I have hex numbers such as

  • 0

I am making an application in C# and I have hex numbers such as 0x0FF8,0xFFFA etc.

Here I want only 12 bit from right to left. Suppose I have a number as 0x0FF8.
So I just want to make operation on FF8.(12 bits), and this is signed number.

It is the decimal number is -8. In my application I have to first find whether number is negative or not? And after that its value.

I am not getting how to do it in C# efficiently as I have to do it very fast.
The number representation is as 0x0FF8= -8 please see the link http://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html

  • 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-11T17:02:51+00:00Added an answer on June 11, 2026 at 5:02 pm

    erm,

    To get the right twelve bits only you could do,

    var right12 = 0x0FFF & yourNumber;
    

    To find out if it negative or positive do,

    var positive = yourNumber >= 0;
    var absoluteValue = Math.Abs(yourNumber); // Assuming yourNumber is Int32
    var low12 = 0xFFF & absoluteValue;
    

    This does a bitwise and against a bit mask for the twelve bits you want to keep.

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

Sidebar

Related Questions

Hi i am making application in c#.I have byte array of containing hex values.I
I am making an application in java and I want to have a terminal
I am making an application in which I have to store data from remote
I am making an android application,I have 4 textviews namely ProductId,Title,description,image.I want when i
im making an application where i have to load my database from html file
I am making an application which will have an interface similar to Photoshop: multiple
I'm making an application for the iPad. I have a view controll that has
I have a application that's making calls against some WCF services I have hosted
I am making a web-based application and i have text-fields where the values are
I am making a CRUD application in jquery and i have this problem in

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.