4 Replies - 912 Views - Last Post: 03 July 2010 - 10:10 AM Rate Topic: -----

#1 ericdavis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#4 ericdavis  Icon User is offline

  • New D.I.C Head

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

Re: Beginner Help - Working With Large Numbers

Posted 03 July 2010 - 10:05 AM

View PostOler1s, 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.
Was This Post Helpful? 0
  • +
  • -

#5 Astraeus  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 23
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1