473,507 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.net 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=317584931803LL;

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
Dec 31 '07 #1
2 1951
James Kanze wrote:
On Dec 31 2007, 5:43 pm, "Victor Bazarov" <v.Abaza...@comAcast.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
Jan 1 '08 #2
To***************@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
http://www.cs.virginia.edu/~lcc-win32
Jan 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
4967
by: Tuvas | last post by:
I've been thinking about writing a program to generate the world's largest prime numbers, just for the fun of it. This would require being able to hold an 8000000 digit number into memory (25...
18
11524
by: Brad | last post by:
I have a problem in that I need to change a large decimal value into its hex equivalent. The largest decimal value I need to represent as hex is 25516777215. The problem here is that this number...
18
5610
by: Zero | last post by:
Hi, I am calculating an integer to the pwer of a large integer, e.g. 2^5000. It turns out that the result I always get is zero. I am sure that the result is too large to store in such type...
14
2802
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
17
8460
by: Jeffrey W. Baker | last post by:
Greetings, I have a 23GB data table upon which I am building a primary key of three columns. The data is mounted in a 137GB device and pg_xlog is mounted on a separate 3.5GB device. I have...
22
4419
by: Frinton | last post by:
Hi, I am trying to do some calculations on large numbers (ie 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it doesn't get it quite right. Its always somewhere between 10...
6
2023
by: DCC-700 | last post by:
I am running VB for ASP.Net in VS.Net 2003 and am experiencing extremely slow response in the ide at times and the debugger. Below is additional detail on the problem. Any thoughts are much...
3
8188
by: CFonville | last post by:
I was wondering if there is any way to store large numbers in a variable? With this simple script: var bigpi = 1234567890123456789012345678901234567890123456789012345678901234567890;...
0
22420
by: zephyrus360 | last post by:
This is about a technique to find the mod of a very large integer with a normal small integer. I recently encountered this problem when I needed to compute the modulus of a very large number with...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.