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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:03:40+00:00 2026-06-17T15:03:40+00:00

To be more specific, there are constraints on my assignment that disallow me to

  • 0

To be more specific, there are constraints on my assignment that disallow me to use multiplication and more than 2 if-else statements. The method should take a number, such as 0xAAA5, and replace one of the 4-bit sections with the given nibble, such as 0x1. Here is my code right now:

public static int setNibble(int num, int nibble, int which) {
    num = num & (0xFFFF - (0xF << (4 * which)));
    num = num | ( (nibble) << (4 * which) );

    return num;
}

I basically just want to left shift by which*4, but I can’t figure out how to do that without multiplication, or some kind of if-else statement.

  • 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-17T15:03:42+00:00Added an answer on June 17, 2026 at 3:03 pm

    4 * which == which << 2, so you can use that.

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

Sidebar

Related Questions

In a recent question of mine I learned that if there are more than
I'm reviving this question, and making it more specific: Is there a .NET framework
Is there a way to determine which ClassLoader loads a specific class? Or more
I do have something more specific in mind, however: Each web service method needs
I'm often confused by CSS override rules: in general, I realize that more specific
In some of our projects, there's an class hierarchy that adds more parameters as
To be more specific I do not know what the exact values will be.
Surely an ordered set is a more-specific case of a set, so why does
Exists a way to call .net assemblies more specific .dll files in java? I
How to find out the more specific error situations like whether the error is

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.