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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:16:33+00:00 2026-06-05T16:16:33+00:00

I have little unusual problem to solve. I need some hint or links to

  • 0

I have little unusual problem to solve. I need some hint or links to get started with. I have queue with 10 data slots. Once the queue is full I need to send it to a server. However, along with that data, I also send start and end sequence number. Now, this numbers must be unique and in increment order. So, for the first send, start = 1, and end = 10. On second send, it would be start = 11, end = 20, and so on. Once the data from the queue is send, new entries will be recorded from the index 0 in the queue.

How do I solve this efficiently ?

  • 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-05T16:16:35+00:00Added an answer on June 5, 2026 at 4:16 pm

    (There is a lot of context missing from your question, so this is mostly a shot in the dark…)

    Since any 16-bit number can fit in a Java int primitive, you can:

    • Convert a Java int to a 16-bit number by ANDing the number with a suitable bitwise mask:

      i16 = i32 & 0xffff
      

      WARNING: This conversion is lossy and not easily reversible.

    • Convert a 16-bit number to a 32-bit int by keeping a separate epoch int that is incremented by one on each roll-over:

      if (previous16 > current16)
          epoch += 1;
      
      current32 = (epoch << 16) | current16;
      

      I do not think that it can get much more efficient than that in Java. Not to mention that any CPU that can run Java would normally run circles around any 16-bit processor, except perhaps for some DSPs…

    A couple of related concerns:

    • Beware of signed/unsigned conversions: Java does not have unsigned types, which may complicate things, depending on what exactly your are doing.

    • Please note that, according to the JLS, the byte, char and short primitive types are implicitly converted to int for all operations. Whether they are actually narrower than 32-bits when stored in memory is implementation specific. And yes, that makes the short type pretty much useless…

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

Sidebar

Related Questions

I have little problem. I can't use AcceptVerb.Get on some ASP.NET MVC actions because
I have little problem that I have been trying to solve for some time.
I have little problem to get file name after upload (PHP script for upload
I have little problem, maybe somebody knows solution??? Usually to get two ID using
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have little snippet for validatin' my form. I need help to position the
i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I have little problem with a replacement of a little part in an url.
I have little problem in regular expressin creation. Expected input: blahblahblah, blahblahblah, 'blahblahblah', blahblahblah,
I have little experience in Java/Groovy/Grails, about 1 year using Eclipse and some weeks

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.