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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:56:13+00:00 2026-05-31T23:56:13+00:00

I have a number, for example 1234567897865; how do I max it out and

  • 0

I have a number, for example 1234567897865; how do I max it out and create 99999999999999 ?

I did this this way:

        int len = ItemNo.ToString().Length;
        String maxNumString = "";

        for (int i = 0; i < len; i++)
        {
            maxNumString += "9";
        }

        long maxNumber = long.Parse(maxNumString);

what would be the better, proper and shorter way to approach this task?

  • 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-31T23:56:14+00:00Added an answer on May 31, 2026 at 11:56 pm
    var x = 1234567897865;  
    return Math.Pow(10, Math.Ceiling(Math.Log10(x+1e-6))) - 1;
    

    To expand on comments below, if this problem was expressed in hex or binary, it could be done very simply using shift operators

    i.e., “I have a number, in hex,, for example 3A67FD5C; how do I max it out and create FFFFFFFF?”

    I’d have to play with this to make sure it works exactly, but it would be something like this:

    var x = 0x3A67FD5C;  
    var p = 0;
    while((x=x>>1)>0) p++;          // count how many binary values are in the number
      return (1L << 4*(1+p/4)) - 1; // using left shift, generate 2 to 
                                    // that power and subtract one
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this programming problem. I have number for example 1000. Now I have
I have a number of elements with the same class like this: <html> <head><title>example</title>
I have the following variable in a class named Example: private static int number;
I have example this number: 5032 I want to get this: 5.0.32 How can
Let's say I have this number 0601811002 and I want cut the number. Example
For example, i have undefined number of a pairs(key, value). And I want to
If I have the following example file where each number is represents a byte
For example, if we have a table Books, how would we count total number
Anyone knows how to get sum of number? For example i have mysql column
For example : I have the number of list like below : {12,23,34,45,65} to

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.