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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:18:56+00:00 2026-06-07T02:18:56+00:00

I have a .txt file that contains a 500 million digit binary representation of

  • 0

I have a .txt file that contains a 500 million digit binary representation of Pi.

I need to use a string representation of that in my program. I also need to be able to search it for substrings and the like – in other words, I need to be able to treat it like a normal sized string. I’ll be trying to find a lot of substrings so speed is necessary.

My initial logic was to simply copy and paste the string directly into the program and use it as a static variable.. But I was unable to actually open the .txt file, so I couldn’t copy and paste. My next attempt was to read the entire string from the file, but I can’t do this in a static method and it takes WAAAY too long (I actually don’t know exactly how long it takes, I closed the program eventually).

Is it possible to do this? Any help would be appreciated.

Edit: Potentially relevant information:

With this code:

/// <summary>
    /// Gets a 500 million binary digit representation of Pi.
    /// </summary>
    public static string GetPi()
    {
        //as per http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx
        StreamReader piStream = new StreamReader(@"C:\binaryPi.txt");
        string pi = "";
        string line;

        while ((line = piStream.ReadLine()) != null)
        {
            pi += line;
        }

        return pi;
    }

I get an OutOfMemoryException.. So scanning the file actually doesn’t seem possible, unless I’m missing something..

  • 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-07T02:18:59+00:00Added an answer on June 7, 2026 at 2:18 am

    so with the information available, i would just declare a bitarray (initial size as file.length) then i would open the file and reading it by chunk of maybe 4096 then you look trough these 4096 characters

    in the loop you just do a simple if text = 1 then set true else set false

    do this until you reach the end of the file then you have the full thing into a huge bitarray variable

    from that point on you just need to find your pattern

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

Sidebar

Related Questions

I have a 1.2GB file that contains a one line string. What I need
I have a LONG .txt file that contains almost 6000 lines! Sometimes I need
I have a txt file that contains data which I need to input to
I have a .txt file that contains a list of names and some numbers.
I have a blacklist.txt file that contains keywords I want to remove using sed.
I have a txt file that is generated on the server and contains newlines.
What I have is a txt file that is huge, 60MB. I need to
I have a text ( .txt ) file that contains Java code! I want
I have a text file words.txt that contains english words. Let's assume it contains
i have a auth.txt file that contains a username and password. my aim is

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.