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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:45:42+00:00 2026-05-15T08:45:42+00:00

as a side project I am working on some home-baked prime generation problems, trying

  • 0

as a side project I am working on some home-baked prime generation problems, trying to write some different implementations as a means of teaching myself C and C++. Of course, the quickest way to generate low primes is to already have them, so I want to go about setting up a hard disk prime list data file. I want to write all the code that generates primes, but I have no qualms about using already made storage methods. I have very little experience when it comes to actual coding, but understand most of the theory. (note that for most of this I will be talking about mathematical integers, rather than the int variables)

So I have some questions to ye, the experts:

1) The naive approach would just be to binary-write the integers as they are generated. However, in my head I imagine a list with items separated by some sort of flag, so that integers larger than 32 bits can be stored (if I get to that point). This is obviously inefficient, but something where the raw data for the array [4723, 12782, 8357] would look like 4723F12782F8357 that is, numbers are stored in base ten with 16 bits per digit and separated by F’s. Obviously the data for ABCDE digit possibilities would be unused, so it’s not a very efficient system, but you see what I mean. This would also make more and more sense as numbers get longer, since any in any fixed-length system the smallest entry would have to be as big as the largest. I’m sure there has to be something already written in C or C++ that does this efficiently.

2) Another possibility is a length-declaration system, where before each integer is stored, a fixed-length (lets say 1 byte) piece of data declares how long the integer is going to be (in bits). This obviously confers similar advantages to the previous option, with the added bonus of not wasting digit possibilities.

Does anyone know of how one would go about storing this kind of data? Is there a variable type I can store primes in so as not to run into size limits? Even better, what is the most efficient way to store a simple list of integers to hard disk in an easily retrievable format?

  • 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-15T08:45:42+00:00Added an answer on May 15, 2026 at 8:45 am

    Don’t reinvent the wheel. If you’re dealing with large primes, you almost certainly want a BigNum library, such as GMP (http://gmplib.org/). GMP BigNums have serialization methods, so you can use those to easily write them to disk and read them from disk, leaving you free to think about the algorithm.

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

Sidebar

Related Questions

I'm (trying) to write some (working) C++ in an ObjC project :-) The C++
I am working on a project and need to do some client side validation.
I'm working on a server-side project that consists of several services. Each service is
I am currently working on a small side-project in MVC3. The goal is to
I'm working on a texture management and animation solution for a small side project
I've been working on a web app in Clojure as a side project, and
I'm working on the UI side of a WPF project. My favourite reference while
Client side Validation and ValidationSummary is working fine for my project (MVC4 + Razor
Im working in a project.Its server side application is in ofbiz.I want to read,edit,update,etc
I'm working on a side project to build a new web app idea of

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.