It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I was working on a factorial program, and the program didn't work when trying to find the factorial of 1000. I think big integers are the solution; how do they work? (In either C or C++)
GMP can do bigint operations for both C and C++. The documentation on that site is a good introduction, if you use the C++ classes they behave almost exactly like built-in primitive types.
Look for the GMP. See the other question regarding this topic:
Handling very large Integers
C++ Big Integer
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am working on a project in school and I need to create a 160 bit value. I haven't programmed in a while so I can't figure out how I would implement this. Any help would be appreciated.
You need a library for big integers (assuming you can't just take a ready-to-use cryptographic library).
First you create a random 160-bit value, not necessarily prime. Depending on the platform, you may use /dev/random, CryptGenRandom, or some other enthropy source(s), (possible several ones, combined).
Then you increment the value in a loop, applying e.g. Miller-Rabin (pseudo-)primality test to each candidate, until you find a prime number.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
A really basic question:
Considering an unsigned integer value, we would like to check that is not equal to 0. Using != or >, which one would be more efficient to use in C++?
Is your application too slow? If it is, the first thing you should do is profile -- this will show you what is causing your program to be slow.
If you aren't having efficiency issues with your program then you shouldn't be worried about this. In fact, worrying about speed at this stage is a bad thing because often people write less readable code in an attempt to improve speed when it's not even an issue.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am currently learning C++ and now understand things like classes and pointers, etc.
Anyone have an idea of what programs I should practice writing when teaching myself C++?
Try reading books that have exercises at the end of every chapter and try making them.
You can check Thinking in C++. The books are available online and they have exercises at the end of each chapter.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
As you know, C++ allows multiple inheritance. But, would it be a good programming approach to use multiple inheritance or it should be avoided?
Thanks.
In general, it's not needed and can make your code more complex.
But there are cases where it's useful. As long as it's useful and isn't causing your code to become unmanageable, I see no reason to avoid it.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Before I knew that C was faster than C++ I was able to write some simple code where C executed faster than C++'s speed.
So my question is: please explain then reason behind this.
If this has already been explained elsewhere on this site or the internet, please share a link.
The reason behind this is your poor test.
C is not faster than C++ because C++
is a superset of C.
Here it is!