Is there any particular solution for handling operations with, let's say, 50 digit numbers or more, without the help of third-party libraries?
This is a discussion on Doing operations with very large numbers? within the C++ Programming forums, part of the General Programming Boards category; Is there any particular solution for handling operations with, let's say, 50 digit numbers or more, without the help of ...
Is there any particular solution for handling operations with, let's say, 50 digit numbers or more, without the help of third-party libraries?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Any tips on doing that? I came up with a solution that may not work or may not be efficient, basically store the number in a char array and then convert each element of the array to a integer and pass them to a integer array and start doing the operations and work from there....
Do you know how to do + - * / on paper?
If you know that, then sure it's very easy.Code:12 +34 =46
It might not be particularly quick, but it will work.
If you want efficiency, without using an existing library, then expect lots of hard work and research.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I didn't want to use any third-party library for such a thing myself either, so I wrote my own, well two of them actually.
They store the data as binary, one dynamically allocated, the other not.
I'm considering writing another one that stores it as a string, also.
Do you really want to know how to make your own? If so, you make a start, and we'll point you at a few resources on how to do the bits you aren't sure of.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"