cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
getting exact numbers
getting exact numbers
Jul 27, 2012 at 7:52pm UTC
rkk94
(4)
hey, im working on a problem on project euler where i have to find the sum of all primes under 2 million. The answer im getting is in scientific notation. Is there some way to make the program give me the exact answer?
Thanks in advance
Jul 27, 2012 at 8:03pm UTC
Peter87
(11234)
Primes are integers so use integer data types instead of floating point data types.
Jul 27, 2012 at 8:07pm UTC
rkk94
(4)
yeah but the answer is in terms of the power 11
unsigned long has a range of about 4 to the power 9,
is there a larger data type i dont know of?
Jul 27, 2012 at 8:28pm UTC
Peter87
(11234)
If your compiler supports it you can use unsigned long long.
Jul 27, 2012 at 8:53pm UTC
rkk94
(4)
thanks tht seemed to do the trick:D
Topic archived. No new replies allowed.