Extremely large numbers in c++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Todd.Branchflower@gmail.com

    Extremely large numbers in c++

    Hey everyone,

    I am new to c++ and the group and would appreciate your help.

    I was doing a problem on projecteuler.ne t in which you had to find the
    largest factor of an extremely large number. Unfortunately, I didn't
    know how to accommodate a number of this size in c++. After
    developing my algorithm and writing it in c++, I wrote the program in
    ruby (a bit easier for large numbers) and found the answer. Looking
    in the forum at other people's code, I was able to change mine to
    work:

    #include <iostream>
    #include <cmath>
    using namespace std;

    int main() {

    long long N=317584931803L L;

    for (long long int i=2; i<=sqrt(N); i++) if (!(N%i)) N/=i;

    cout << N;

    string wait;

    cin >wait;

    return 0;
    }


    My question is, what is the significance of the LL convention
    following the number?? Why won't the code work without it? Also,
    some people didn't need the LL when they declared N as __int64. This
    doesn't work on my compiler (Dev-C++), as the compiler says the number
    is too large for the __int64 data type. Why? Final question, how can
    I compile programs at the command line with Dev-C++?

    Thanks in advance for your help,
    Todd
  • Victor Bazarov

    #2
    Re: Extremely large numbers in c++

    James Kanze wrote:
    On Dec 31 2007, 5:43 pm, "Victor Bazarov" <v.Abaza...@com Acast.net>
    wrote:
    >Todd.Branchflo ...@gmail.com wrote:
    >>I am new to c++ and the group and would appreciate your help.
    >[...]
    [.. doctorate thesis on something that is *not* in C++ *now* ..]
    If on the 1st of January, you're spending time correcting somebody
    else's answers on Usenet, you need to get a life. Seriously.

    Happy New Year!

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • jacob navia

      #3
      Re: Extremely large numbers in c++

      Todd.Branchflow er@gmail.com wrote:

      Hi Todd.

      If you do not mind using plain C (with some C++ like operator
      overloading) you should use lcc-win, a free compiler for windows.

      It features 352 bits floating point, 128 bit integers, true
      long double (80 bits) and other goodies. It has too an
      extensive math library.

      Download it at the URL below

      --
      jacob navia
      jacob at jacob point remcomp point fr
      logiciels/informatique

      Comment

      Working...