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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:52:26+00:00 2026-05-26T08:52:26+00:00

I’m having the hardest time trying to get my class to work properly. It’s

  • 0

I’m having the hardest time trying to get my class to work properly. It’s a natural number class with methods like increase and decrease. I’m trying to make it immutable, and I’m stuck. If I increment a number such that it’s least significant digit isn’t 9, it works fine. But once I get to the boundary case, it fails.

IE. I have a number that’s 69999, I increment it and it’s 7.

private SlowBigNatural(int[] natural, int nSize){
    this.nSize = nSize - 1;
    this.natural = new int[this.nSize];
    for (int i = 0; i < this.nSize; i++) {
        this.natural[i] = natural[i];
    } 
}
@Override
public BigNatural increment() {
    int[] nClone = natural.clone();
    if (nSize == 1 || nClone[nSize - 1] != HIGHEST) {
        nClone[nSize - 1]++;
        String nString = "";
        for(int i = 0; i < nSize; i++){
            nString += String.valueOf(nClone[i]);
        }
        BigNatural nInc = new SlowBigNatural(nString);
        return nInc;
    } 

    else {
        nClone[nSize - 1] = 0;
        BigNatural temp = new SlowBigNatural(nClone, nSize);
        return temp.increment();
    }
}
  • 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-05-26T08:52:27+00:00Added an answer on May 26, 2026 at 8:52 am

    I’m a little confused as to the endianness of your BigNatural. You don’t explicitly mention how you’re storing your number. You can either store with the most significant digit first, or least significant digit first.

    That is the number 12,345 can be stored as {1,2,3,4,5} (Big Endian) or {5,4,3,2,1} (Little Endian).

    If your increment is correct then getting 7 from adding 1 to 69,999 is likely a problem with endianness.

    That is {7,0,0,0,0} is 70,000 if Big Endian or 7 if Little Endian. Check the string constructor. See what endianness it expects.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words

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.