Beginner Help - Working With Large Numbers

Page 1 of 1

4 Replies - 1231 Views - Last Post: 03 July 2010 - 10:10 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=180045&amp;s=32d245298a82282348e402eb01bc42bc&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 ericdavis

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 03-July 10

Beginner Help - Working With Large Numbers

Posted 03 July 2010 - 06:13 AM

I just began to learn C++ a couple days ago, and it is my first programming i've done. I would really like to know how to work with really large numbers, preferably with no limit to the amount of digits(if that is possible) Could someone please point me in the right direction? Below is something I have written and that I would like to be able to use with really large numbers.
```#include <iostream>

using namespace std;

int main()

{
int x, y, z, p;

cin>> x;
cin>> y;
z = x * y;
p = z + 1;
cout<< p <<"\n";
z = z * p;
p = z + 1;
cout<< p <<"\n";
cin.get();

}
```

Is This A Good Question/Topic? 0

Replies To: Beginner Help - Working With Large Numbers

#2 Eclipse Reborn

Reputation: 10
• Posts: 135
• Joined: 26-June 10

Re: Beginner Help - Working With Large Numbers

Posted 03 July 2010 - 06:53 AM

A long double is 8 bytes, and can contain up to 15 digits.

#3 Oler1s

• D.I.C Lover

Reputation: 1397
• Posts: 3,884
• Joined: 04-June 09

Re: Beginner Help - Working With Large Numbers

Posted 03 July 2010 - 09:47 AM

Quote

I would really like to know how to work with really large numbers
It's called arbitrary precision arithmetic.

Quote

preferably with no limit to the amount of digits(if that is possible)
There's always a limit. Infinite limit means infinite storage. Which means you have an infinite amount of hardware. If you know how to get infinite hardware, be sure to let me know ASAP.

#4 ericdavis

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 03-July 10

Re: Beginner Help - Working With Large Numbers

Posted 03 July 2010 - 10:05 AM

Oler1s, on 03 July 2010 - 08:47 AM, said:

Quote

I would really like to know how to work with really large numbers
It's called arbitrary precision arithmetic.

Quote

preferably with no limit to the amount of digits(if that is possible)
There's always a limit. Infinite limit means infinite storage. Which means you have an infinite amount of hardware. If you know how to get infinite hardware, be sure to let me know ASAP.

ahaha, I meant as in the program would be able to handle as many digits as my hardware could store, cause right now its limited to like 10 digits or something. I'll look into arbitrary precision arithmetic, thanks for that.

#5 Astraeus

Reputation: 23
• Posts: 205
• Joined: 17-November 09

Re: Beginner Help - Working With Large Numbers

Posted 03 July 2010 - 10:10 AM

Well, there are different data types that can store different memory..

There's a tutorial here