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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:02:57+00:00 2026-06-17T05:02:57+00:00

I am working in java and came across an odd block of code that

  • 0

I am working in java and came across an odd block of code that my fellow college wrote i’m sure the modulus operator would work but for some reason i’m not getting the expected results i thought i would from the operator.

right now the code is written as follows:

long divisionID = myMaxId % 40;
                if (divisionID == 0) {
                    divisionID = 1;
                }
                long empiresubID = 1;
                if (myMaxId >= 1600) {
                    empiresubID = 2;
                }
                if (myMaxId >= (1600 * 2)) {
                    empiresubID = 3;
                }
                if (myMaxId >= (1600 * 3)) {
                    empiresubID = 4;
                }
                if (myMaxId >= (1600 * 4)) {
                    empiresubID = 5;
                }
                if (myMaxId >= (1600 * 5)) {
                    empiresubID = 6;
                }

it’s like this for a few other places and this goes up through 1600*40.

i thought using the modulus operator for myMaxId %1600 but that gave me way incorrect results.

the end goal is there are 40 divisions, we first fill sub division 1 for all divisions first using myMaxID % 40 as users register.

then once that is done the subdivision would then flip to 2, then we fill in all the divisions subdivision 2.

i don’t think the way it’s currently programmed is efficient and there should be some other way to do this.

any thoughts or help on this would be great.

  • 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-17T05:02:58+00:00Added an answer on June 17, 2026 at 5:02 am

    I think you can get rid of the chain of ifs by replacing with

    long empiresubID = (myMaxId / 1600) + 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently came across some odd behavior that involves Java's regex engine. When writing
While working on a WebSocket server in Java I came across this strange bug.
I was working with java code that is supposedly using the Factory pattern, but
While working with JOCl (java version opencl), I came across this error. Exception in
I am working on a more complete email validator in java and came across
I have a decent working web application (Java/Servlet/Jsp) that I would like to improve
In the code I am currently working on I came across a piece code
I came across an oddity today that I don't quite understand. Take this code,
I'm working with Java 4; some time ago I came across a variable which
I have been working on Google AdWords and came across this code adwords-api-6.4.0, com.google.api.adwords.lib.AdWordsUser

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.