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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:50:15+00:00 2026-06-15T03:50:15+00:00

I’m currently reading a long number from a string. The number is 3 integer

  • 0

I’m currently reading a long number from a string. The number is 3 integer digits followed by 7 decimal digits without a decimal (e.g. 1234567890).

How can I divide this number before parsing it?

I’m trying to parse it into an integer, but an integer has a ~2 billion maximum value.

Here is what I have tried:

class Program
{
    static void Main(string[] args)
    {
        using (StreamReader reader = new StreamReader("CLIFF.dat"))
        {
            string line;
            var locations = new Dictionary<string, int[]>() {
                {"210", new [] {405, 4, 128, 12, 141, 12, 247, 15}}, 
                {"310", new [] {321, 4, 112, 12, 125, 12, 230, 15}}, //
                {"410", new [] {477, 4, 112, 12, 125, 12, 360, 15 }} 
            };
 while ((line = reader.ReadLine()) != null)
            {                 
                    var lineStart = line.Substring(0, 3);

                    if (lineStart == "210" || lineStart == "310" || lineStart == "410")
                    {
                        var currentLocations = locations[lineStart];
                        var letters = line.Substring(currentLocations[0], currentLocations[1]);

                        var transactionvolume =
                            int.Parse(line.Substring(currentLocations[2], currentLocations[3])) +
                            int.Parse(line.Substring(currentLocations[4], currentLocations[5]));
                        var watching = line.Substring(currentLocations[6], currentLocations[7]);
                        var number = int.Parse(line.Substring(currentLocations[6], currentLocations[7])*));

It’s the current location[6] number that is too large and needs to be multiplied by 10^-7.

  • 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-15T03:50:16+00:00Added an answer on June 15, 2026 at 3:50 am

    Shameful rollup of the comments into an answer:

    The problem is that a 32-bit signed integer can handle, at most, a value of 2.1 billion (2,147,483,647 to be precise). The value as translated directly from the string is too big.

    The possible strategies, as outlined in the comments, are:

    • Use a larger datatype. Long, double, decimal, bigint etc are all capable of handling numbers in the tens of billions and higher (though with floating-point types, the higher it goes the less precision it has). Since you want a floating-point type and you’re expecting 7 decimal places, personally I’d go with Decimal; it’s the largest datatype at 128 bits, but it has the best precision of a floating type, meaning you can expect to put any integer value in it, divide by 107 and get the right answer.

    • Divide and conquer. You already have the number as a string, and you know it has exactly 7 decimal points. You therefore know where to put a decimal point into the string such that it can be parsed into a floating-point type:

      decimal myValue = decimal.Parse(myString.Substring(0, myString.Length-7) 
                                  + "." 
                                  + myString.Substring(myString.Length-7, 7));
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I want use html5's new tag to play a wav file (currently only supported

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.